$report = @()
Get-VM | Get-View | %{
$row = "" | select Path, Name, PowerState, DiskUsed
$row.Name = $_.Name
$current = Get-View $_.Parent
$path = $_.Name
do {
$parent = $current
if($parent.Name -ne "vm"){$path = $parent.Name + "\" + $path}
$current = Get-View $current.Parent
} while ($current.Parent -ne $null)
$row.Path = $path
$report += $row
}
$report | Export-Csv -Path .\report.csv -NoTypeInformation -UseCulture
Okay actually I have this solution to find Path + Name of VM.
Can somebody help me to insert for example PowerState to the prepared row? I will get how to obtain another data and that's it. Thanks!