Fix #1099: Only populate site result when it is there

pull/18777/head
Brian Geihsler 9 years ago committed by Matt Clay
parent 002fc53863
commit 2f6f6cedf8

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

Loading…
Cancel
Save