PS Script to pull Sites from IISRSS

1 reply

Last post Apr 10, 2020 01:31 AM by lextm

  • PS Script to pull Sites from IIS

    Apr 10, 2020 01:14 AM|Turn360|LINK

    I am working on a Powershell script to run against IIS servers.  I am trying to return the Hostname and URL.   I am running into an issue getting the URL the server is hosting.  Below are two the different routes I have taken so far (WMI and Get-Website)

    PS WMI

    Get-WmiObject -authentication 6 -class "IIsWebServerSetting" -namespace "root\microsoftiisv2" | select-object __SERVER, ServerComment, Name 

    **************************************

    PS using Get-Website

    $WebsiteData = Get-Website

    $Webobj = New-Object PSObject

    $Webobj | Add-Member NoteProperty -Name "Name" -Value $env:COMPUTERNAME
    $Webobj | Add-Member NoteProperty -Name "WebsiteName" -Value ($WebsiteData.Name -join ',')
    $Webobj | Add-Member NoteProperty -Name "Bindings" -Value ($WebsiteData.Bindings -join ",")

    write-output $Webobj | export-CSV -path C:\temp\Website_Test.csv -NoTypeInformation

  • Re: PS Script to pull Sites from IIS

    Apr 10, 2020 01:31 AM|lextm|LINK

    Turn360

    I am running into an issue getting the URL the server is hosting

    What URL do you want to query?

    Lex Li
    IIS Consulting Services at https://support.lextudio.com/services/consulting.html
    ---------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.