#!/usr/bin/perl
use Win32::OLE qw(in);
$Win32::OLE::Warn = 3;
print "Please enter the hostname you are looking for:\n";
print "?: ";
chomp($domain = <STDIN>);
# ------ SCRIPT CONFIGURATION ------
$strComputer = 'localhost'; # e.g. web01.rallencorp.com
# ------ END CONFIGURATION ---------
$objIIS = Win32::OLE->GetObject('IIS://' . $strComputer . '/W3SVC');
foreach my $objSite (in $objIIS) {
if (($objSite->Class eq 'IIsWebServer')) {
#print $objSite->ServerComment . ' (' . $objSite->Name . ')';
$ServerBindings = $objSite->{ServerBindings};
foreach $item (@{$ServerBindings}) {
$item =~ /(.*):(.*):(.*)/;
$hostheader = $3;
if ($hostheader =~ /[a-zA-Z0-9-\.]+/) {
if($hostheader =~ /$domain/){
print $objSite->ServerComment.' - '.$hostheader,"\n";
}
}
}
}
}