I am trying to build powershell program which would:
- connect to the remote server
- Show number of active IIS app pools on the active server
- based on the selection (1,2,3,4,....n etc) it would reset app pool
thanks!
I am trying to build powershell program which would:
thanks!
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.
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.
You need to know how to access the IIS cmdlets form the WebAdministration Module
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!
Ā
Jason
Ā
Ā
hi Jason,
thanks for info, I have started writing something:
Code is accepting server name
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 $iis $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
ticationā.
At H:\scripts\apppool.ps1:6 char:128
any idea what went wrong?
thanks!
Hello Martin. Ć Can you try changing:
<PowerShell>-Authentication PacketPrivacy</PowerShell>
to
<PowerShell>-Authentication 6</PowerShell>
Ā
same error as above:
Get-WmiObject : A parameter cannot be found that matches parameter name Ć¢ā¬ĖAuthen
ticationĆ¢ā¬ā¢.
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.
Ā