Skip to content

Commit 9398c0d

Browse files
committed
Checking if resources are returned
1 parent e399dc4 commit 9398c0d

3 files changed

Lines changed: 17 additions & 5 deletions

File tree

NetScaler/Public/Get-NSLBMonitor.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ function Get-NSLBMonitor {
5555
if ($Name.Count -gt 0) {
5656
foreach ($item in $Name) {
5757
$monitors = _InvokeNSRestApi -Session $Session -Method Get -Type lbmonitor -Action Get -Resource $item
58-
return $monitors.lbmonitor
58+
if ($monitors.psobject.properties.name -contains 'lbmonitor') {
59+
return $monitors.lbmonitor
60+
}
5961
}
6062
} else {
6163
$monitors = _InvokeNSRestApi -Session $Session -Method Get -Type lbmonitor -Action Get
62-
return $monitors.lbmonitor
64+
if ($monitors.psobject.properties.name -contains 'lbmonitor') {
65+
return $monitors.lbmonitor
66+
}
6367
}
6468
}
6569
}

NetScaler/Public/Get-NSLBServer.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,16 @@ function Get-NSLBServer {
5656
foreach ($item in $Name) {
5757
$response = _InvokeNSRestApi -Session $Session -Method Get -Type server -Resource $item -Action Get
5858
if ($response.errorcode -ne 0) { throw $response }
59+
if ($Response.psobject.properties.name -contains 'server') {
5960
$response.server
6061
}
62+
}
6163
} else {
6264
$response = _InvokeNSRestApi -Session $Session -Method Get -Type server -Action Get
6365
if ($response.errorcode -ne 0) { throw $response }
64-
$response.server
66+
if ($Response.psobject.properties.name -contains 'server') {
67+
$response.server
68+
}
6569
}
6670
}
6771
}

NetScaler/Public/Get-NSLBServiceGroup.ps1

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,15 @@ function Get-NSLBServiceGroup {
5555
if ($Name.Count -gt 0) {
5656
foreach ($item in $Name) {
5757
$serviceGroups = _InvokeNSRestApi -Session $Session -Method Get -Type servicegroup -Action Get -Resource $item
58-
return $serviceGroups.servicegroup
58+
if ($ServiceGroups.psobject.properties.name -contains 'servicegroup') {
59+
return $serviceGroups.servicegroup
60+
}
5961
}
6062
} else {
6163
$serviceGroups = _InvokeNSRestApi -Session $Session -Method Get -Type servicegroup -Action Get
62-
return $serviceGroups.servicegroup
64+
if ($ServiceGroups.psobject.properties.name -contains 'servicegroup') {
65+
return $serviceGroups.servicegroup
66+
}
6367
}
6468
}
6569
}

0 commit comments

Comments
 (0)