Share via


matching zone on IISsettings

$webApps = Get-SPWebApplication

$path = 'C:\Windows\System32\inetsrv\config\applicationHost.config'

$xml = [xml](Get-Content -Path $path)

if($webApps -ne $null -and $xml -ne $null)

{

foreach($webApp in $webApps)

{

foreach($zone in $webApp.IisSettings.keys)

{

$node = $xml.SelectSingleNode("/configuration/system.applicationHost/sites")

if($node -ne $null)

{

$site = $node.site | ?{$_.Id -eq $webApp.IisSettings[$zone].PreferredInstanceId}

if($site -eq $null)

{

'IIS Site not found. Provisioning web app: {0}' -f $webApp.DisplayName | Out-Host

$webApp.Provision()

}

elseif((Test-Path -Path $webApp.IisSettings[$zone].Path) -eq $false)

{

'Path not found. Provisioning web app: {0}' -f $webApp.DisplayName | Out-Host

$webApp.Provision()

}

}

}

}