VMware Cloud Community
mark_chuman
Hot Shot
Hot Shot
Jump to solution

vCenter Unique ID

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 Smiley Sad    

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

7 Replies
Jalapeno420
Enthusiast
Enthusiast
Jump to solution

Any of these give you want you need?

$a = connect-viserver vcserver

$a.uid

$a.id

$a.instanceuuid

LucD
Leadership
Leadership
Jump to solution

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

mark_chuman
Hot Shot
Hot Shot
Jump to solution

Thanks!

Reply
0 Kudos
mark_chuman
Hot Shot
Hot Shot
Jump to solution

Also found this as an fyi for others.

https://communities.vmware.com/thread/436671

Reply
0 Kudos
AjayNadakuditi
Contributor
Contributor
Jump to solution

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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

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

AjayNadakuditi
Contributor
Contributor
Jump to solution

Thats Awsome LucD.  Thanks for the quick response.

Reply
0 Kudos