Mallik7
Enthusiast
Enthusiast

looking for a script

Jump to solution

hello, looking for a powercli script to help to get the list of VMs from a vCenter along with cluster name and vCenter.

format should be like this -

vCenter name - VM name - Cluster name

this output should be saved in a .csv format

TIA

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Get-Cluster -PipelineVariable cluster |

Get-VM | ForEach-Object -Process {

    New-Object -TypeName PSObject -Property @{

        vCenter = ([System.Uri]$_.ExtensionData.Client.ServiceUrl).Host

        Cluster = $cluster.Name

        VM = $_.Name

    }

} | Select vCenter, VM, Cluster |

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


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

View solution in original post

4 Replies
LucD
Leadership
Leadership
Get-Cluster -PipelineVariable cluster |

Get-VM | ForEach-Object -Process {

    New-Object -TypeName PSObject -Property @{

        vCenter = ([System.Uri]$_.ExtensionData.Client.ServiceUrl).Host

        Cluster = $cluster.Name

        VM = $_.Name

    }

} | Select vCenter, VM, Cluster |

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


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

View solution in original post

Mallik7
Enthusiast
Enthusiast

thanks, but, it is not capturing the vCenter name. can you please have look

0 Kudos
LucD
Leadership
Leadership

Corrected


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

0 Kudos
Mallik7
Enthusiast
Enthusiast

its working as expected. thank you LucD

0 Kudos