Does anyone have a PowerShell Script to list IIS websites from an external server ?

Hi Everyone,

I have a Windows 2012 R2 server, and I need to audit the number of IIS websites we have across the server estate. Does anyone have a PowerShell script that will audit for IIS website that are hosted on Windwos 2003 servers upwards ?

Appreciate anyones help.



Hi CaussyR,

Do you have the web servers in a specific OU or would you just like to search each and every box?

Regards

Guy



Hi CaussyR,

Do you have the web servers in a specific OU or would you just like to search each and every box?

Regards

Guy



I would like to scan the whole server exstate, but as a starter AD would be fine.



In the time of asking this question, I have put to gether the following :
$Servers = get-content 'c:tempServerList.txt'

cls
try {
foreach ($Hostname in $Servers)
{

Write-Output $Hostname
Get-WmiObject -Authentication PacketPrivacy -Impersonation Impersonate -ComputerName $Hostname -namespace "root/MicrosoftIISv2" -class IIsApplicationPool | `
Select-Object -property @{N="Name";E={$name = $_.Name; $name.Split("/")[2] }} | Format-Table
}
} Catch{

Write-Output $Hostname + "Does not have IIS"
}

I get the Web App pools but not sure which WMI object to use to list the web site name.



Keep in mind the MicrosoftIISv2 root namespace will only work with II7 or IIS6 after you install the WMI Compatibility features. If you have not done this it won't work on your 2003 boxes unless you've updated to IIS of course...

You can use this to list the classes in the namespace.

Get-WmiObject -Namespace rootmicrosoftiisv2 -list



By the way, instead of using a server list, install ad tools and run this to get all the servers

Import-Module ActiveDirectory
$Servers = Get-ADComputer -Filter * -Properties OperatingSystem |`
Where {$_.OperatingSystem -like "*Server*"} | Select Name

Share this

Related Posts

There was an error in this gadget