Maros94
Maros94

Reputation: 1

How do I start and stop several IIS Applicationpools at once with a PowerShell script

I would like to create a PowerShell script that can Start and Stop several IIS Applicationpools at once.

I already found a similar article about this: How to start and stop application pool in IIS using powershell script

But I would like to create a PowerShell script where I can define more than one IIS Application to stop them all at once through that script.

Thank you in advance for the help

Upvotes: 0

Views: 1997

Answers (1)

Zé Cláudio
Zé Cláudio

Reputation: 113

The link you provided already has a solution very close to what you need; look for "Stop all application pools script".

If you want to start/stop only some AppPools, put them in an array: replace $AppPools=Get-ChildItem IIS:\AppPools | Where {$_.State -eq "Started"} with $AppPools=@('server1', 'server2', 'server3'):

$AppPools=@('server1', 'server2', 'server3')

ForEach($AppPool in $AppPools) {
   Stop-WebAppPool -name $AppPool.name
}

Upvotes: 1

Related Questions