Hi,
been banging my head a bit lately on this one.
When I run Get-VM | select VMHost, Name I get a return on the VMhost and the guest.
If I add a tad to the selection such as Get-Snapshot and a few more selections I do not get the VmHost but all the rest of the information comes along just fine.
Get-VM | Get-Snapshot | select VMHost, Name, Description, SizeMB
Can anybody be so kind as to point out what I am doing wong.
Finally this is part of something I plan to run a bit more thoroughly so the whole line is something like this:
Get-VM | Get-Snapshot | select VMHost, Name, Description, SizeMB, @{N="DaysOld"; E={((Get-Date) - $_.Created).Days}} | ? {$_.DaysOld -gt 7} | Export-Csv "C:\Filename.csv"
The commandlet works but just not with the host, which quitely franky would be useful to have
//Martin
Message was edited by: maishsk Subject was changed
oi Martin,
you are selecting properties from a snapshot object and not from a virtual machine object. A snapshot object has different properties. You can use the following code:
Get-VM | Get-Snapshot | Select-Object -Property @{N="VMHost";E={$_.VM.VMHost.Name}}, @{N="VM";E={$_.VM.Name}}, Name, Description, SizeMB, @{N="DaysOld"; E={((Get-Date) - $_.Created).Days}} | Where-Object {$_.DaysOld -gt 7} | Export-Csv "C:\Filename.csv" -NoTypeInformation -UseCulture
Message was edited by: maishsk Subject was corrected
oi Martin,
you are selecting properties from a snapshot object and not from a virtual machine object. A snapshot object has different properties. You can use the following code:
Get-VM | Get-Snapshot | Select-Object -Property @{N="VMHost";E={$_.VM.VMHost.Name}}, @{N="VM";E={$_.VM.Name}}, Name, Description, SizeMB, @{N="DaysOld"; E={((Get-Date) - $_.Created).Days}} | Where-Object {$_.DaysOld -gt 7} | Export-Csv "C:\Filename.csv" -NoTypeInformation -UseCulture
Message was edited by: maishsk Subject was corrected
Hi Robert,
thanks worked a charm! I was kinda hoping that was what the problem was, still new with this though.
//Martin
Message was edited by: maishsk Subject was corrected