List all VMDK and in which Datastore they are in?
open powercli
connect-viserver vcenter@domain.com
save the following as VMDK.ps1
$outputFile = "C:\vmdk.csv"
$VMsAdv = Get-VM | Sort-Object Name | % { Get-View $_.ID }
$myCol = @()
ForEach ($VMAdv in $VMsAdv)
{
ForEach ($Disk in $VMAdv.Layout.Disk)
{
$myObj = "" | Select-Object Name, Disk
$myObj.Name = $VMAdv.Name
$myObj.Disk = $Disk.DiskFile[0]
$myCol += $myObj
}
}
$myCol | Export-Csv $outputFile -NoTypeInformation
run in powershell
connect-viserver vcenter@domain.com
save the following as VMDK.ps1
$outputFile = "C:\vmdk.csv"
$VMsAdv = Get-VM | Sort-Object Name | % { Get-View $_.ID }
$myCol = @()
ForEach ($VMAdv in $VMsAdv)
{
ForEach ($Disk in $VMAdv.Layout.Disk)
{
$myObj = "" | Select-Object Name, Disk
$myObj.Name = $VMAdv.Name
$myObj.Disk = $Disk.DiskFile[0]
$myCol += $myObj
}
}
$myCol | Export-Csv $outputFile -NoTypeInformation
run in powershell
Comments
Post a Comment