‘Post-deployment Command Line’. snap-in ‘Microsoft.SharePoint.PowerShell' is not installed on this computer.
hi all,
i try run powershell script automatically when deploying sharepoint farm solution, keep receiving error messages.
i first create sharepoint folder called powershell scripts , place powershell script (spdeploy.ps1).
*************
spdeploy.ps1:
$snapin = get-pssnapin | { $_.name -eq "microsoft.sharepoint.powershell" }
if($snapin -eq $null) {
add-pssnapin microsoft.sharepoint.powershell
}
write-host "reset iis"
iisreset
write-host "delete demo site"
remove-spsite -identity "http://mysite/sites/test1" -gradualdelete -confirm:$false
write-host "create demo site"
new-spsite http://mysite/sites/test1 -owneralias "domain\administrator" -name "contoso" -template "sitedefinition1#0"
write-host "finished"
***************
i add commands visual studio ‘post-deployment command line’. have tried 3 different commands, still received error messages.
command 1)
%systemroot%\syswow64\windowspowershell\v1.0\powershell.exe set-executionpolicy -executionpolicy unrestricted
%systemroot%\syswow64\windowspowershell\v1.0\powershell.exe -file "$(projectdir)\poweshellscripts\psdeploy.ps1"
command 2)
c:\windows\system32\windowspowershell\v1.0\powershell.exe set-executionpolicy -executionpolicy unrestricted
c:\windows\system32\windowspowershell\v1.0\powershell.exe -file "$(projectdir)\poweshellscripts\psdeploy.ps1"
command 3)
%windir%\system32\windowspowershell\v1.0\powershell set-executionpolicy unrestricted -file "$(projectdir)\poweshellscripts\psdeploy.ps1"
%windir%\system32\windowspowershell\v1.0\powershell -file "$(projectdir)\poweshellscripts\psdeploy.ps1"
while deploying sharepoint solution error message shown below:
*****************
add-pssnapin : windows powershell snap-in ‘microsoft.sharepoint.powershell' not installed on computer.
at c:\users\administrator\documents\visual studio 2013\projects\sharepointsiteproj\sharepointsiteproj\poweshellscripts\psdeploy.ps1:7 char:1
+ add-pssnapin microsoft.sharepoint.powershell
+ categoryinfo : invalidargument: (microsoft.sharepoint.powershell:string) [add-pssnapin], psargumentexception
+ fullyqualifiederrorid : addpssnapinread,microsoft.powershell.commands.addpssnapincommand
remove-spsite : term 'remove-spsite' not recognized name of cmdlet, function, script file, or operable program. check spelling of
name, or if path included, verify path correct , try again.
at c:\users\administrator\documents\visual studio 2013\projects\sharepointsiteproj\sharepointsiteproj\poweshellscripts\psdeploy.ps1:21 char:1
+ remove-spsite -identity "http://robin/sites/test2" -gradualdelete
-confirm:$fals ...
+ categoryinfo : objectnotfound: (remove-spsite:string) [], commandnotfoundexception
+ fullyqualifiederrorid : commandnotfoundexception
…
*****************
i can run same script manually sharepoint powershell console without error message, run automatically visual studio ‘post-deployment command line’.
i hope can help
colin
indeed thats correct because running in 32 bit version. wont work. try run 64 bit version.
the 64 bit ps should here
%systemroot%\system32\windowspowershell\v1.0\powershell.exe
for example
%systemroot%\syswow64\windowspowershell\v1.0\powershell.exe set-executionpolicy -executionpolicy unrestricted
change
%systemroot%\system32windowspowershell\v1.0\powershell.exe set-executionpolicy -executionpolicy unrestricted
and try. let me know
one more thing file name reads spdeploy when calling called psdeploy. not clear here please check too.
regards chen v [mcts sharepoint 2010]
Windows Server > Windows PowerShell
Comments
Post a Comment