|
|
|
@ -59,7 +59,7 @@ function Get-ACSUserByName {
|
|
|
|
|
)
|
|
|
|
|
$resturl = "/Rest/Identity/User/name/"
|
|
|
|
|
$result = Invoke-WebRequest -UseBasicParsing -WebSession $session -Method GET -Uri "$($acs)$($resturl)$($username)"
|
|
|
|
|
return $result.Content
|
|
|
|
|
return [xml]$result.Content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get devices that are conform with supplied filter (in XML format)
|
|
|
|
@ -72,7 +72,7 @@ function Get-FilterDevicesByName {
|
|
|
|
|
$header = @{"Content-type" = "application/xml"}
|
|
|
|
|
$resturl = "/Rest/NetworkDevice/Device/op/query"
|
|
|
|
|
$result = Invoke-WebRequest -UseBasicParsing -WebSession $session -Method PUT -Uri "$($acs)$($resturl)" -Body $filter -Headers $header
|
|
|
|
|
return $result.Content
|
|
|
|
|
return [xml]$result.Content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get locations list (either all, or that match $filter)
|
|
|
|
@ -92,7 +92,7 @@ function Get-AllLocations {
|
|
|
|
|
$resturl = "/Rest/NetworkDevice/DeviceGroup/op/query"
|
|
|
|
|
$result = Invoke-WebRequest -UseBasicParsing -WebSession $session -Method PUT -Uri "$($acs)$($resturl)" -Headers $header -Body $filter
|
|
|
|
|
}
|
|
|
|
|
return $result.Content
|
|
|
|
|
return [xml]$result.Content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Get all devices (XML) assigned to $location and save XML to files
|
|
|
|
@ -117,12 +117,8 @@ function Get-DevicesByLocation {
|
|
|
|
|
# Query devices
|
|
|
|
|
$result = Invoke-WebRequest -UseBasicParsing -WebSession $session -Method PUT -Uri "$($acs)$($resturl)" -Headers $header -Body $filter
|
|
|
|
|
|
|
|
|
|
# Format result
|
|
|
|
|
$result.Content | Set-Content -Path tmp_devices.xml
|
|
|
|
|
$parsed = [xml](Get-Content tmp_devices.xml)
|
|
|
|
|
|
|
|
|
|
# Loop thru all received devices
|
|
|
|
|
$devs = Select-Xml -xml $parsed -XPath //Device
|
|
|
|
|
$devs = Select-Xml -xml $result -XPath //Device
|
|
|
|
|
foreach ($dev in $devs) {
|
|
|
|
|
"`t$($dev.node.id);$($dev.node.name);$($dev.node.subnets.ipAddress)" | Out-Host
|
|
|
|
|
}
|
|
|
|
@ -177,7 +173,7 @@ function Get-LocationIDByName {
|
|
|
|
|
)
|
|
|
|
|
$resturl = "/Rest/NetworkDevice/DeviceGroup/name/Location:$($location)"
|
|
|
|
|
$result = Invoke-WebRequest -UseBasicParsing -WebSession $session -Method GET -Uri "$($acs)$($resturl)"
|
|
|
|
|
return $result.Content
|
|
|
|
|
return [xml]$result.Content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Find device by Name and return its XML
|
|
|
|
@ -197,7 +193,7 @@ function Get-DeviceByName {
|
|
|
|
|
"Error occured during data retrieval for $($name)" | Write-Host
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
return $result.Content
|
|
|
|
|
return [xml]$result.Content
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Delete location by its ID
|
|
|
|
|