Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to start/stop Website and application pool on another server while deploying my project?

l.aizdi November 13, 2019

Currently I am using this Powershell script which runs before deployment. 

$Password=Convertto-SecureString -String ${bamboo.deploy.password} -AsPlainText -force
$Credentials=New-object System.Management.Automation.PSCredential ${bamboo.deploy.username},$Password
Enter-PSSession -ComputerName ${Server} -Credential $Credentials
Invoke-Command -ScriptBlock {start cmd;cd C:\Windows\System32\inetsrv;appcmd stop apppool /apppool.name:"${app_pool_name}"}

 

But it gives the following error:

The term 'appcmd' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

 

I have also tried using the Stop-WebAppPool cmdlet. It also gave an error saying Stop-WebAppPool is not recognized as the name of any cmdlet. I have also tried Import-Module WebAdministration before Stop-WebAppPool cmdlet. It also was not successful.

1 answer

0 votes
Jimmy Seddon
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 2, 2021

Hi @l.aizdi,

Sorry no one has been able to help you with this issue yet.

Looking at it, my first thought would be to check what Powershell modules are installed/imported on your web server.

Stop-WebAppPool is not a part of the standard Powershell library.  It's part of the WebAdministration Module which would need to be imported ahead of running the command.

What you can do, is add an if block to check if the WebAdministration module exists, and if not run:

Import-Module WebAdministration

I understand you may have solved this already but if not, I hope that might help you out.

-Jimmy

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events