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:tempServerList.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
}
}



I think you will need to do this via WMI https://msdn.microsoft.com/en-us/library/ms525309.aspx
examples: https://gallery.technet.microsoft.com/scriptcenter/site/search/?f%5b0%5d.Type=Tag&f%5b0%5d.Value=IIS%206.0



I think you will need to do this via WMI https://msdn.microsoft.com/en-us/library/ms525309.aspx
examples: https://gallery.technet.microsoft.com/scriptcenter/site/search/?f%5b0%5d.Type=Tag&f%5b0%5d.Value=IIS%206.0









Share this

Related Posts

There was an error in this gadget