how to operate On List of IIS Application Pools On Remote Server Using Powershel

I am trying to build powershell program which would:

  1. connect to the remote server
  2. Show number of active IIS app pools on the active server
  3. based on the selection (1,2,3,4,....n etc) it would reset app pool
I am newbie in powershell so I am not sure where to start, can you please give me some tips?

thanks! :slight_smile:

Hi Martin!


The script you want to write is not inherently hard, but the challange you face is that it requires some knowledge of PowerShell. Even if I wrote you one (which is not the goal to these forums) you wouldn’t be able to get it to run. Â Let me see if I can get you pointed in the right direction. Â I’m happy to help with specific questions as you progress.

  1. You need to use PowerShell Remoting to manage IIS servers remotly. This needs to be enabled on the target servers, plus may require permission from your security department.

  2. You need to know how to access the IIS cmdlets form the WebAdministration Module

  3. You need to know what a provider is and how to access information through one. In your case, you will want to access the IIS provider.

The best course of action would be to go through the first 18 chapters of Don Jones “LEarn Windows PowerShell 3 in a Month of Lunches”. Â This will get you almost everything you need to build the script. I’ll be happy to point out specifics if you post your work here.

Also, for IIS spefic information gathering using PowerShell, you can check out the book “Learn Windows IIS in a Month of Lunches” - however it requires that you have the basic PowerShell skills discussed in Don’s book first.

Hope this helps getting you started!





hi Jason,

thanks for info, I have started writing something:

  1. Code is accepting server name

  2. I have found iis Get-wmiObject info command which could possibly display/accept IIS application settings

for example:

$server_name = Read-Host 'SERVER NAME:'

foreach($vm in $server_name)

$iis = Get-WmiObject -Namespace root\MicrosoftIISv2 -Class IIsApplicationPoolSetting -ComputerName $server_name -Authentication PacketPrivacy


	$i = $iis.Count

		for ($k = 0; $k -lt $i; $k++)

			$name = $iis[$k].Name


I assume get-WmiObject creates connection between.

when i ran this script i have got:

Get-WmiObject : A parameter cannot be found that matches parameter name ‘Authen
At H:\scripts\apppool.ps1:6 char:128

any idea what went wrong? :slight_smile:

thanks! :slight_smile:

Hello Martin. Â Can you try changing:

<PowerShell>-Authentication PacketPrivacy</PowerShell>


<PowerShell>-Authentication 6</PowerShell>


same error as above:

Get-WmiObject : A parameter cannot be found that matches parameter name ‘Authen
At H:\scripts\apppool.ps1:6 char:128

Well, one way is

Get the list of apppools

Invoke-command -ComputerName web1,web2 {Get-WebAppPool}

Invoke-Command -CompteName Web1,Web2 {Restart-webapppool -name <ppolname>}


However - Without PowerShell Remoting this wont work.