Utilities.ps1
function Get-MetasysRootDevice { param( [int]$Version, # Skips certificate validation checks. This includes all validations # such as expiration, revocation, trusted root authority, etc. # [!WARNING] Using this parameter is not secure and is not recommended. # This switch is only intended to be used against known hosts using a # self-signed certificate for testing purposes. Use at your own risk. [Switch]$SkipCertificateCheck ) <# .SYNOPSIS Uses the current Metasys session to find and return the root device. This is the object that represents the device the session is connected to. .OUTPUTS System.Object. The root device. .EXAMPLE PS> Read-MetasysRootDevice id : a68f10e5-da10-5b87-a96b-42a36e9919ae itemReference : R12AdsDaily:R12AdsDaily name : R12AdsDaily objectType : objectTypeEnumSet.adsClass description : firmwareVersion : 12.0.0.7508 objectCategory : objectCategoryEnumSet.systemCategory timeZone : timeZoneEnumSet.centralTime self : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae parentUrl : networkDevicesUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/networkDevices equipmentUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/equipment spacesUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/spaces objectsUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/objects trendedAttributesUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/trendedAttributes alarmsUrl : https://r12adsdaily.cg.na.jci.com/api/v4/networkDevices/a68f10e5-da10-5b87-a96b-42a36e9919ae/alarms ipAddress : 172.21.57.4 certificateExpirationDate : 9/8/2023 4:55:25 PM pairing : @{supported=True; paired=False} .EXAMPLE PS> Read-MetasysRootDevice | Select-Object -ExpandProperty id a68f10e5-da10-5b87-a96b-42a36e9919ae In this example we use 'Select-Object' to return just the 'id' of the root object. #> # TODO: This version assumes the session is established with a site director as # at the time of writing the API is not exposed on any other devices. # Also, it assumes there is only one server on a site (no child ADSs) Write-Host $args imm /networkDevices?classification=server -ReturnBodyAsObject -Version:$Version | Select-Object -ExpandProperty items -First 1 } function Get-MetasysNetworkTree { $items = Invoke-MetasysMethod /objects?flatten=true -ReturnBodyAsObject | Select-Object -ExpandProperty items $items | ForEach-Object -Parallel { $id = $_.id if (($_.classification -eq 'server') -or ($_.classification -eq 'device')) { Invoke-MetasysMethod "/objects/$id/objects?flatten=true&depth=2" -ReturnBodyAsObject | Where-Object { $_.items } | Select-Object -ExpandProperty items | Where-Object { $_.id -ne $id } } } -ThrottleLimit 3 } function Find-MetasysObject { param( [int]$ObjectType, [int]$Version, [Switch]$SkipCertificateCheck ) } Export-ModuleMember -Function "Read-MetasysRootDevice" |