VMware Cloud Community
Mallik7
Enthusiast
Enthusiast
Jump to solution

Bulk VMs guest UUID requirement

Hello, I'm in need of a power CLI script that helps to grab the VM UUID information of the given from a input file... I've a list of VMs about 400 which I want to input them in a text file. Script should be able to taken and provide the output in a .csv file

TIA

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-VM -Name (Get-Content -Path .\infile.txt) |

Select Name,

    @{N='vCenter';E={([uri]$_.ExtensionData.Client.ServiceUrl).Host}},

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

Export-Csv -Path .\outfile.csv -NoTypeInformation -UseCulture


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

View solution in original post

6 Replies
LucD
Leadership
Leadership
Jump to solution

What do you actually have in the input file?
VM name, UUID...?

And what should go in the output CSV file?


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Like this (where I assume the input file has the VM's name, one per line)?

Get-VM -Name (Get-Content -Path .\infile.txt) |

Select Name,

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

Export-Csv -Path .\outfile.csv -NoTypeInformation -UseCulture


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

Reply
0 Kudos
Mallik7
Enthusiast
Enthusiast
Jump to solution

Hello,

in the input file the VM name

and if a VM has more number of disks that are created on multiple datastores, those needs to be updated in the output CSV file against each VM

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Disks?
You lost me now.

What exactly should go into the output file?

Can you show a mockup?


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

Reply
0 Kudos
Mallik7
Enthusiast
Enthusiast
Jump to solution

sorry for the confusion. I'm all set with the output. THANKS

however, is it possible to display in the output file from which vCenter the VM belongs to...(against each VM)

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, try like this

Get-VM -Name (Get-Content -Path .\infile.txt) |

Select Name,

    @{N='vCenter';E={([uri]$_.ExtensionData.Client.ServiceUrl).Host}},

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

Export-Csv -Path .\outfile.csv -NoTypeInformation -UseCulture


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