I need to get a list of the VM swap location and Swap size. I was able to use the script below to get some information but was missing the size data and some of the output was being cut off. Is it possible to add the size data to the script below and have it export to a CSV file? Or is another script needed to get the swapfile name/location and then use that data to query/get the size. Any help is greatly appreciated.
Thanks
foreach($vminGet-VM){
$vm|SelectName,@{N='VMX';E={$vm.ExtensionData.Config.Files.VmPathName.Split('/')[0]}},
@{N='Swap';E={
switch($vm.ExtensionData.Config.SwapPlacement){
'inherit' {
$parent=Get-View$vm.ExtensionData.ResourcePool -PropertyName,Parent
while($parent-isnot[VMware.Vim.ClusterComputeResource]){
$parent=Get-View$parent.Parent -PropertyName,Parent
}
$parent=Get-View$parent.MoRef -PropertyConfigurationEx.VmSwapPlacement
switch($parent.ConfigurationEx.VmSwapPlacement){
'hostLocal' {
$esx=Get-View$vm.ExtensionData.Runtime.Host -PropertyConfig.Local.SwapDatastore
$swapLocation=Get-View$esx.Config.LocalSwapDatastore -PropertyName
}
'vmDirectory' {
$swapLocation=$vm.ExtensionData.Config.Files.VmPathName.Split('/')[0]
}
}
}
'hostLocal' {
$esx=Get-View$vm.ExtensionData.Runtime.Host -PropertyConfig.Local.SwapDatastore
$swapLocation=Get-View$esx.Config.LocalSwapDatastore -PropertyName
}
'vmDirectory' {
$swapLocation=$vm.ExtensionData.Config.Files.VmPathName.Split('/')[0]
}
}
$swapLocation
}}}