Upon deployment completion, we are using the IIS AppPool - Restart step template to restart the app pool for our deployed WCF service.
We get this error during this step:
WARNING: The names of some imported commands from the module
Info 10:50:01
’Library_IISutils_635422277996919883’ include unapproved verbs that might make
Info 10:50:01
them less discoverable. To find the commands with unapproved verbs, run the
Info 10:50:01
Import-Module command again with the Verbose parameter. For a list of approved
Info 10:50:01
verbs, type Get-Verb.
Error 10:50:01
Add-PSSnapIn : An item with the same key has already been added.
Error 10:50:01
At C:\Users\octopus\AppData\Local\Tentacle\Temp\d6d02cb1-f14b-4784-a754-7e653d9
Error 10:50:01
87b9e.ps1:17 char:13
Error 10:50:01
-
Add-PSSnapIn WebAdministration;
Error 10:50:01
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error 10:50:01
+ CategoryInfo : NotSpecified: ( [Add-PSSnapin], ArgumentExcept
Error 10:50:01
ion
Error 10:50:01
+ FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Co
Error 10:50:01
mmands.AddPSSnapinCommand
Info 10:50:02
PowerShell exit code: 1
Fatal 10:50:02
PowerShell script returned a non-zero exit code: 1
Note, I had to modify original template to work with older server / powershell 3.0. If I run this script manually outside of Octopus it seems to work without error. Not sure on why it fails in context of Octopus.
Set-StrictMode -Version Latest
Load IIS module:
Import-Module WebAdministration
http://stackoverflow.com/questions/1924217/powershell-load-webadministration-in-ps1-script-on-both-iis-7-and-iis-7-5/4325963#4325963
$iisVersion = Get-ItemProperty “HKLM:\software\microsoft\InetStp”;
if ($iisVersion.MajorVersion -eq 7)
{
if ($iisVersion.MinorVersion -ge 5)
{
Import-Module WebAdministration;
}
else
{
if (-not (Get-PSSnapIn | Where {$_.Name -eq “WebAdministration”;})) {
Add-PSSnapIn WebAdministration;
}
}
}
Get AppPool Name
$appPoolName = $OctopusParameters[‘appPoolName’]
Start App Pool if stopped else restart
if ((Get-WebAppPoolState($appPoolName)).Value -eq “Stopped”){
Write-Output "Starting IIS app pool $appPoolName"
Start-WebAppPool $appPoolName
}
else {
Write-Output "Restarting IIS app pool $appPoolName"
Restart-WebAppPool $appPoolName
}
Windows Version 6.0.6002
Powershell 3.0
please advise.