mark_chuman
Hot Shot
Hot Shot

vCenter Unique ID

Jump to solution

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

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

Any of these give you want you need?

$a = connect-viserver vcserver

$a.uid

$a.id

$a.instanceuuid

LucD
Leadership
Leadership

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

Thanks!

0 Kudos
mark_chuman
Hot Shot
Hot Shot

Also found this as an fyi for others.

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

0 Kudos
AjayNadakuditi
Contributor
Contributor

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

0 Kudos
LucD
Leadership
Leadership

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

Thats Awsome LucD.  Thanks for the quick response.

0 Kudos