Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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 use strict; use Win32::OLE; use Win32::OLE::Enum; 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; foreach (@vhosts){ print "$_\n"; }

In reply to Win32::OLE and IIS by abdiel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2024-04-23 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found