Old 13th December 2011, 13:23   #1
mmahajan9
Junior Member
 
Join Date: Dec 2011
Posts: 6
Run Powershell script using NSIS

Hi,

I am creating a setup file to deploy sharepoint WebApplication. I will have to first create a web application on the IIS and SharePoint Farm. For this I have a Powershell script which will do all that for me. I wanted to execute this powershell script using nsis.
I tried this :
SetOutPath $INSTDIR\CGD
File Files\CGDirectSiteInstallation.ps1
Execwait "$INSTDIR\CGD\CGDirectSiteInstallation.ps1"
but I am not able to execute this PS1 file.
Also this PS1 file will accept some parameters which will be taken from user.

Please let me know if I am doing anything wrong or how to execute this ps1 file?
Execution of this ps1 file should be silent.

Thanks & regards,
Mayur Mahajan
mmahajan9 is offline   Reply With Quote
Old 13th December 2011, 13:33   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You only ExecWait executable files. Use ExecShell to open/launch a file with its default registered application.
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.1.3
MSG is offline   Reply With Quote
Old 13th December 2011, 16:20   #3
mmahajan9
Junior Member
 
Join Date: Dec 2011
Posts: 6
Running SharePoint Powershell in NSIS

Thanks a lot for the quick reply.

But I am getting some problem for running the ps1 file through NSIS. It is as follows :
I have used some SharePoint commands like "New-SPAuthenticationProvider" and "New-SPWebApplication". So while executng these commands it gives me following errors :
"The term 'New-SPAuthenticationProvider' is not recognized as the name of a cmdlet, function, script file, or operable program."

To make this execute properly I tried to execute Add-PSSnapin command which is as follows : "Add-PSSnapin Microsoft.SharePoint.PowerShell".
After executing this command I am getting an error as :
Add-PSSnapin : No snap-ins have been registered for Windows PowerShell version 2

I tried to get solution on google, but in vein.

If I ran the same ps1 file through SharePoint Powershell then I didn't get any errors and the Web Application gets created successfully.

Please suggest a way to get out of this. Is there any other method through which we can create web application on IIS as well as on SharePoint Farm?


Thanks & regards,
Mayur Mahajan.
mmahajan9 is offline   Reply With Quote
Old 13th December 2011, 16:38   #4
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
I've no idea what powershell is, but if you need to run the script through powershell, I suggest you try to execute powershell with your ps1 file as a parameter.
MSG is offline   Reply With Quote
Old 20th December 2011, 07:31   #5
mmahajan9
Junior Member
 
Join Date: Dec 2011
Posts: 6
Quote:
Originally Posted by MSG View Post
I've no idea what powershell is, but if you need to run the script through powershell, I suggest you try to execute powershell with your ps1 file as a parameter.
Thanks MSG,

I got my problem and meed some help in solving it.
The problem was, to run SharePoint commands I should run the SharePoint script in SharePoint Management shell. So I converted the windows powershell (the window which gets opened after executing ExceShell command) to SharePoint Management shell.
But for now the problem I am getting is, as the Windows Poershell gets converted to SharePoint Management Shell the window gets close. It should not get closed.

Please suggest me solution for this or else suggest another way to create Web Application on IIS, while running the setup file.

My requirement is when the setup starts it should create a new web application on IIS and then SharePoint Farm.

Please do let me know about this. I have been doing work on this since very long time and the NSIS and NSIS is the last hope.
mmahajan9 is offline   Reply With Quote
Old 20th December 2011, 07:39   #6
mmahajan9
Junior Member
 
Join Date: Dec 2011
Posts: 6
Or else can you please suggest me how to open SharePoint Powershell (i.e. SharePoint Management Shell) directly.
I meant to say that, when we use ExecShell command then it opens Windows Powershell. So can we directly open the SharePoint Powershell (i.e. Sharepoint Management Shell)
mmahajan9 is offline   Reply With Quote
Old 20th December 2011, 10:06   #7
jpderuiter
Major Dude
 
Join Date: Feb 2007
Posts: 672
http://social.technet.microsoft.com/...b-1f101de9e583

http://dmitrysotnikov.wordpress.com/...in-a-bat-file/
jpderuiter is offline   Reply With Quote
Old 7th January 2014, 18:19   #8
chbrosso
Junior Member
 
Join Date: Jan 2014
Posts: 2
I wrote macros to ease the use of PowerShell script or commands in NSIS here: http://nsis.sourceforge.net/PowerShell_support
chbrosso is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump