In continuing with my IIS Security realted coding, I am trying to perform a simple audit of all virtual hosts on a server. These can be accessed via OLE/the Metabase under (IIS://server/w3svc/<instance>/root). I can access the information I need (IP address, web root) just fine when I know the instance I want to look at. My problem is that I don't know the number of Virtual Hosts I should be looking at on a particular server.
This brought me to look into Win32::OLE::Enum (Makes sense, I am using OLE, and I want to enumerate the container objects under the w3svc object). So far, the following code will give me hash references to the Virtual host objects I need, but I can't dig into them. I've tried using ->as_string to see what the values are, but that doesn't work.
Is there a method I can use in Win32::OLE or Win32::OLE::Enum that would do what I'm looking for? I don't really even need to know the Identifier, as long as I can look into the Root object to pull the info I need.
This code lists the objects by Hash Reference.
#! perl -w
Win32::OLE->Option(Warn => 3);
my $hostname = shift;
my $rootkey = shift;
my $Collection = Win32::OLE->GetObject("IIS://$hostname/w3svc");
my $virts = Win32::OLE::Enum->new($Collection);
my @vhosts = $virts->All;