Anyone aware of a way to get at the vCenter unique ID via powercli or sdk? Having no luck finding anything on retrieving this setting outside of the manual GUI. I hate to have to go digging in the vCenter registry
Try like this
$si = Get-View ServiceInstance
$setting = Get-View $si.Content.Setting
$setting.QueryOptions("instance.id") | Select -ExpandProperty Value
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Any of these give you want you need?
$a = connect-viserver vcserver
$a.uid
$a.id
$a.instanceuuid
Try like this
$si = Get-View ServiceInstance
$setting = Get-View $si.Content.Setting
$setting.QueryOptions("instance.id") | Select -ExpandProperty Value
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks!
Also found this as an fyi for others.
Hi LucD,
I have a requirement to query and change the vCenter Server Unique ID using PowerCli. Using your code, I can query the vCenter unique id. Can you please let me know how can I change it?
-Ajay
Sure, try like this
It will get a random number (between 0 and 63) that is different from the current ID
$si = Get-View ServiceInstance
$setting = Get-View $si.Content.Setting
$id = $setting.QueryOptions("instance.id") | Select -ExpandProperty Value
$newid = $id
while($newid -eq $id){
$newid = Get-Random -Minimum 0 -Maximum 64
}
$optvalue = New-Object VMware.Vim.OptionValue
$optvalue.Key = "instance.id"
$optvalue.Value = $newID
$setting.UpdateOptions($optvalue)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thats Awsome LucD. Thanks for the quick response.