0

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

$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.

Edit: When I use the same script from my localhost, it works successfully. When I use this script on BAMBOO, it gives the above mentioned error. Is it possible that the WebAdministration Module is not installed on the agent's environment or Bamboo server?

  • 1
    Possible duplicate of [The term 'appcmd' is not recognized as the name of a cmdlet](https://stackoverflow.com/questions/24945542/the-term-appcmd-is-not-recognized-as-the-name-of-a-cmdlet) – cdsln Nov 15 '19 at 11:06
  • you could try $systemRoot = [environment]::GetEnvironmentVariable("systemroot") Set-Location $systemRoot\system32\inetsrv .\appcmd or @cdsln suggested link solution. – Jalpa Panchal Nov 18 '19 at 01:59
  • @cdsln I had tried it before posting this query. It didn't work for me. – Leena Aizdi Nov 18 '19 at 06:47
  • @JalpaPanchal It didn't work. The same error occurred. – Leena Aizdi Nov 18 '19 at 06:48

1 Answers1

1

Make sure you enabled IIS Management Scripts and Tools feature of iis.

you could try these steps: 1. Open Turn Windows features on or off.

  1. Enable IIS Management Scripts and Tools under “Internet Information Services” => “Web Management Tools”.

  2. We will see the appcmd.exe in C:\Windows\System32\inetsrv folder then.

  3. Add C:\Windows\System32\inetsrv to PATH system environment variable.

Jalpa Panchal
  • 8,251
  • 1
  • 11
  • 26