PowerShell — Check Class Properties (UCS as Example)
While playing with UCS PowerShell command to adjust initial environment configuration… There are a lot of things that not following the “rule”
Here is the JSON for an Object:
| |
The structure of this object:
- BootPolicy
- BootPolicyConfiguration
- Boot device order
When I’m trying to add the first boot device order object, following command should be run:
| |
This command will pass the PropertyMap as hastable:
- Access
- LunId
- Order
But when I’m running the second boot device order object, if I still running the similar command based on the previous one:
| |
It will trough the error message as

Looks like the “Access” is a read-only property that cannot be set for this object, looks like they are not set in standard by Cisco PowerShell API Developer.
We need to find a way to detect when we need this property and when we don’t.
By using decompiler ILSpy to check the DLL file (Cisco.UcsCentral.dll), find the class called LsbootVirtualMedia, we can see:

But with LsBootStorage

In PowerShell, we can use following method to check this property is writable or not:

We need a more dynamic way as different object has different properties but in the same collection as a part of the Configuration.
So we need do this:
| |
Then we can call following to find the property value we need:
| |
So good luck to my long journey for UCS Automation… River