VMware Cloud Community
vmjogi
Contributor
Contributor

PowerShell to get uuids of each vm

I need to enhance my list of information with the uuid of the vms.

Get-VM SQL-01 | %{(Get-View $_.Id).config.instanceUuid} 

Now I found a nice PowerShell script which has all I need but not the uuid.

Get-VM |

  Select Name,

@{N = 'GuestOS'; E = {$_.ExtensionData.Guest.GuestFullName}},

@{N = "Datastore"; E = {[string]::Join(',', (Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},

@{N = "UsedSpaceGB"; E = {[math]::Round($_.UsedSpaceGB, 1)}},

@{N = "ProvisionedSpaceGB"; E = {[math]::Round($_.ProvisionedSpaceGB, 1)}},

@{N = "Folder"; E = {$_.Folder.Name}}

@{N = "UUID"; E = {[string]::Join(',', (Get-View $_.Id).config.uuid | Select -ExpandProperty Name))}} |

Sort-Object -Property Folder

but the UUID line is not working and I don't get my error. What I was looking for to enhance this list with the UUID.

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Try like this

Get-VM |

Select Name,

@{N = 'GuestOS'; E = {$_.ExtensionData.Guest.GuestFullName}},

@{N = "Datastore"; E = {[string]::Join(',', (Get-Datastore -Id $_.DatastoreIdList | Select -ExpandProperty Name))}},

@{N = "UsedSpaceGB"; E = {[math]::Round($_.UsedSpaceGB, 1)}},

@{N = "ProvisionedSpaceGB"; E = {[math]::Round($_.ProvisionedSpaceGB, 1)}},

@{N = "Folder"; E = {$_.Folder.Name}},

@{N='UUID';E={$_.ExtensionData.Config.Uuid}} |

Sort-Object -Property Folder


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos