PowerShell: SharePoint - Output IIS and AAM Settings

Updated on 2/7/2015

These are the same values visible in central admin but it can be useful to access them using a script.

$webApp = Get-SPWebApplication http://sharepoint:81

#output WebApp IIS Settings
foreach($zone in $webApp.IisSettings.Values)
{	
	Write-Host $zone.ServerComment
	$bindings = $zone.ServerBindings;			
	foreach($binding in $bindings.GetEnumerator())
	{
		$hostheader = $binding.HostHeader
		$port = $binding.Port.ToString()
		Write-Host "     Binding: $hostheader : $port"
	}	
	
}

#output WebApp alternate access mappings
foreach($aam in $webApp.AlternateUrls)
{
	Write-Host "Zone - "$aam.UrlZone 
	Write-Host "Incoming -" $aam.IncomingUrl 
	Write-Host "Public -" $aam.PublicUrl 
}