Avatar of CaussyR
CaussyR
 asked on

List Website Details from a Windows 2003 R2 Server ?

I am currently in the process of auditing the Windows 2003 servers running PS 2.0.  I have written the script below and run it from Powershell 4 on a Windows 2012 R2 server.  Does any one know how I cna modify it so it can also grab the IIS site details from a Windwos 2003 server ? The script works on a 2012 server.

        Import-Module WebAdministration
        Get-WebApplication
        # $webapps = Get-WebApplication
        $Servers = Get-Content 'c:\temp\ServerList.txt'
        $webapps = Get-WebSite
        $list = @()
   
   Foreach ($Hostname in $Servers)
   {
    try{
        foreach ($webapp in get-childitem IIS:\Sites\)
        {
            $name = "IIS:\Sites\"
            $item.Hostname = $Hostname
            $item.Name = $webapp.name
            $item.State = (Get-Website -Name $webapp.name).State
            $item.PhysicalPath = (Get-Website -Name $webapp.name).PhysicalPath
            $obj = New-Object PSObject -Property $item
            $list += $obj
        }

        $list | Format-Table -a -Property "Hostname","Name", "State", "PhysicalPath"

        }catch
        {
            $ExceptionMessage = "Error in Line: " + $_.Exception.Line + ". " + $_.Exception.GetType().FullName + ": " + $_.Exception.Message + " Stacktrace: " + $_.Exception.StackTrace
            $ExceptionMessage
        }
    }
PowershellMicrosoft Legacy OSWindows OS

Avatar of undefined
Last Comment
Nadav Solomon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Nadav Solomon

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Nadav Solomon

Glad I could help, thanks for the feedback.
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck