none
How do I get the web site names from a remote computer

    Question

  • I have been asked for a way to query serveral thousnad servers that have IIS installed to see if they have active Web sites.

    I have found a way to get the IISApplicationPool  but that does not get me the actual site name or Sites Names.

    $a = Get-WmiObject IISApplicationPool -Computer $srv -Namespace root\MicrosoftIISv2 -Authentication PacketPrivacy

    This gets some other information:

    $c = Get-WmiObject -class iiscomputer -Computer $srv -namespace root\microsoftiisv2 -authentication 6

    And get-website does not seem to work for remote computers.

    Is there a Get-WmiObject Class that would give me this information?

    The next step would be to associate the Application Pool with the site name.

    Thursday, April 26, 2012 5:26 PM

Answers

All replies

  • IIS6?

    http://www.terminal23.net/2007/10/powershell_list_of_sites_in_ii.html:

    $objSites = [adsi]"IIS://serverorlocalhost/W3SVC"
    foreach ($objChild in $objSites.Psbase.children)
    { $objChild.servercomment }

    Thursday, April 26, 2012 8:32 PM
  • When I run the above, I get all this::

    Default Web Site
    ITC Publishing
    Kerberos Test

    MemberType          : Method
    OverloadDefinitions :
    TypeNameOfValue     : System.Management.Automation.PSMethod
    Value               :
    Name                : servercomment
    IsInstance          : True

    MemberType          : Method
    OverloadDefinitions :
    TypeNameOfValue     : System.Management.Automation.PSMethod
    Value               :
    Name                : servercomment
    IsInstance          : True

    MemberType          : Method
    OverloadDefinitions :
    TypeNameOfValue     : System.Management.Automation.PSMethod
    Value               :
    Name                : servercomment
    IsInstance          : True

    How do I eliminate this stuff  after the site names?

    Friday, April 27, 2012 4:03 PM
  • Hi,

    This should help:

    $objSites = [adsi]"IIS://localhost/W3SVC"
    foreach ($objChild in $objSites.Psbase.children)
    { $objChild.servercomment -as [String] }
    
    Friday, April 27, 2012 7:21 PM
  • This should also work...

    $computers="localhost"

    foreach ($computer in $computers) {

          Get-WmiObject -Namespace root\webadministration -computername $computer -class site | %{ $_.name }

    }

    Joe

    Saturday, April 28, 2012 12:28 AM
  • Hi 
     
    Just checking in to see if the suggestions were helpful. Please let us know if you would like further assistance.
     
    Have a great day!

    Best Regards,
    Yan Li

    TechNet Subscriber Support

    If you are TechNet Subscription user and have any feedback on our support quality, please send your feedback here.


    Yan Li

    TechNet Community Support

    Tuesday, May 01, 2012 2:06 AM
    Moderator