Skip to content

Instantly share code, notes, and snippets.

@mercdev
Created May 2, 2015 23:02
Show Gist options
  • Save mercdev/533a43ce32782144fc7e to your computer and use it in GitHub Desktop.
Save mercdev/533a43ce32782144fc7e to your computer and use it in GitHub Desktop.
Displays IIS Website configuration information
function Pause ($Message="Press any key to continue...")
{
# The ReadKey functionality is only supported at the console (not in the ISE)
if ($PGSE -eq $null)
{
Write-Host -NoNewLine $Message
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Write-Host ""
}
}
cls
try
{
Import-Module WebAdministration
foreach ($website in Get-ChildItem IIS:\Sites\)
{
if ($website.name -eq "Default Web Site")
{
continue
}
"{0} {1}" -f $website.id, $website.name
$currentPath = "IIS:\Sites\"+ $website.name
$isRedirected = (Get-WebConfigurationProperty -filter /system.webserver/httpRedirect -PSPath "$currentPath" -name enabled).value;
if ($isRedirected)
{
$redirectedTo = (Get-WebConfigurationProperty -filter /system.webserver/httpRedirect -PSPath "$currentPath" -name destination).value;
"Redirected to: {0}" -f $redirectedTo
}
#Write-Output $website.state
foreach ($binding in $website.bindings)
{
foreach($protocol in $binding.Collection)
{
if ($protocol.protocol -eq "http" -or $protocol.protocol -eq "https")
{
" {0}" -f $protocol.bindingInformation
}
}
}
}
}
catch
{
$ExceptionMessage = "Error in Line: " + $_.Exception.Line + ". " + $_.Exception.GetType().FullName + ": " + $_.Exception.Message + " Stacktrace: " + $_.Exception.StackTrace
$ExceptionMessage
}
Pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment