Using powershell invoke-command to recycle app pool across multiple servers

Hi there,
I’m trying to use the script task to execute the following powershell to recycle the app pools on a number of remote servers as part of our release. These aren’t the servers with tenacle, hence using the invoke command.

I’ve passed in the domain variables from the project variable and able to get the powershell to execute against the same servers to run a request on them, for example ls d: returns fine from each of the servers so no issues with the ad credentials.

When trying to use the restart-webapppool command with the app pool hard coded it doesn’t error and doesn’t do anything. At first i tried it as a project variable and decided to troubleshoot it with the hard coded app pool name instead.

Any ideas why it’s not recycling the app pool? Nothing is returning in the task and it’s marked as success. (as mentioned swapping the commands to run a basic dir listing returns the data).

Thanks

$Username   = "domain\user"
$PasswordSS = ConvertTo-SecureString $adcredential -AsPlainText -Force
$Cred       = New-Object System.management.Automation.PSCredential $Username,$PasswordSS

Invoke-Command –ComputerName websrv3.mydomain.com, websrv4.mydomain.com, websrv7.mydomain.com –ScriptBlock {
    restart-WebAppPool website-www
} –Credential $cred

Have you tried running this PowerShell script outside of Octopus to verify that it works as expected and potentially debugging further?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.