Merge pull request #1100 from bgeihsgt/win_iis_absent_fix

Fix #1099: Only populate site result when it is there
This commit is contained in:
Brian Coca 2015-10-19 11:29:15 -04:00
commit 679e9fc7b4

View file

@ -171,15 +171,21 @@ Catch
Fail-Json (New-Object psobject) $_.Exception.Message
}
$site = Get-Website | Where { $_.Name -eq $name }
$result.site = New-Object psobject @{
if ($state -ne 'absent')
{
$site = Get-Website | Where { $_.Name -eq $name }
}
if ($site)
{
$result.site = New-Object psobject @{
Name = $site.Name
ID = $site.ID
State = $site.State
PhysicalPath = $site.PhysicalPath
ApplicationPool = $site.applicationPool
Bindings = @($site.Bindings.Collection | ForEach-Object { $_.BindingInformation })
}
}
Exit-Json $result