Script: Finding IIS Servers in Domain

One of our customers is getting ready for a security audit of their critical servers. Indeed Exchange is one of those but there are lot others running IIS on them and exposed to internet through a firewall or some other technology.

Challenge was to find out how many servers in the data center have IIS installed and not in their knowledge. Doing something like this really becomes a challenge when someone has hundreds of servers running inside that cold, noisy and windy storage room Smile with tongue out (Data Center)

Here is a simple script that can help you find the number of IIS servers in an AD domain.


#$Servers = Get-ADComputer -Filter * -ResultSetSize $null -Properties OperatingSystem | ? { ($_.OperatingSystem -like "Windows Server*") -and ($_.Name -like "BLR-*")}
Foreach ($Server in $Servers) {
Write-Host "Connecting to" $Server.DNSHostName -ForegroundColor Blue
if (Get-WmiObject -ComputerName $Server.DNSHostName -Namespace root -Class __NameSpace -Filter "name=’MicrosoftIISv2’" -ErrorAction SilentlyContinue)
    $Found = $Server.DNSHostName
    $Found | Out-File E:\Reports\ServersWithIIS.txt -Force -Append


Write-host $Server.DNSHostName + "does not seem to have IIS on it" -ForegroundColor Green

Again, it is the simplest code that could come upon searching for a ready made script on internet but failing to find one. Hope this helps others too.

One thought on “Script: Finding IIS Servers in Domain”

Comments are closed.