CiscoDevNet / intersight-powershell

Cisco Intersight PowerShell
Apache License 2.0
16 stars 4 forks source link

IntersightEquipmentLocatorLed Questions #128

Closed tbrock47 closed 6 months ago

tbrock47 commented 10 months ago

I'm looking for assistance on the correct syntax to achieve gathering all 'EquipmentLocatorLed' objects that are currently on and turn them off.

Our environment has a mix of UCSM managed and Intersight managed devices, so I need to filter the results by parents that are Intersight managed only.

I know how to get all of the objects that are on, but I don't know how to modify the filter to account for the desired "ManagementMode" of the Parent.

$Results = (Get-IntersightEquipmentLocatorLed -Filter 'OperState eq on').Results

Once that is achieved, I don't understand the syntax required to change the LED (turn off or on). I assume I need to populate the AdditionalProperties parameter, but I am unsure how.

foreach ($Result in $Results) {
    Set-IntersightEquipmentLocatorLed -Moid $Result.Moid
}

Thanks in advance. Although I am very well versed in PowerShell, I am not so much with REST APIs. I have been consulting the apidocs and testing my queries there. https://us-east-1.intersight.com/apidocs/apirefs/All/api/v1/equipment/LocatorLeds

tbrock47 commented 10 months ago

I know that I can process the Parent portion client side, but if the goal is to server side process everything, I need to understand how.

$Results = (Get-IntersightEquipmentLocatorLed -Filter 'OperState eq on' -Expand 'Parent').Results
foreach ($Result in $Results) {
    if ($Result.Parent.ActualInstance.AdditionalProperties.ManagementMode -eq 'Intersight') {
        Set-IntersightEquipmentLocatorLed -Moid $Result.Moid
    }
}
briamorr commented 10 months ago

The LocatorLed endpoint is mostly read only with the exception of tags. To alter the LED state you'll need to update the compute/ServerSettings endpoint and update AdminLocatorLEdState to On/Off. There is an example here:

https://github.com/CiscoDevNet/intersight-powershell-utils/blob/main/led-examples/toggle-server-led.ps1

In regards to doing an $expand and $filter to process everything server side, my understanding is that currently the API backend only supports $select nested with $expand when I had asked in the past.

tbrock47 commented 10 months ago

The LocatorLed endpoint is mostly read only with the exception of tags. To alter the LED state you'll need to update the compute/ServerSettings endpoint and update AdminLocatorLEdState to On/Off. There is an example here:

https://github.com/CiscoDevNet/intersight-powershell-utils/blob/main/led-examples/toggle-server-led.ps1

In regards to doing an $expand and $filter to process everything server side, my understanding is that currently the API backend only supports $select nested with $expand when I had asked in the past.

Thanks for this. I'll try to run with this and adapt it for objects other than Servers (Chassis) that also have LEDs. I guess I have no idea how "Set-IntersightEquipmentLocatorLed" is actually used then.