Hi,
Yes I know... I like to complicate my life. Due to the nature of the teams supporting different OS types in our infra I am looking for a powercli query which will provide a list of VM's for specific OS with snapshots older then 3 days,
I would like to get all *Windows* servers running snapshots older then 3 days, same with *Linux* for whole datecenter,
I already have queries to get snaps older then 3 days:
Get-VM | Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-3)} | Select-Object VM, Name, Created, SizeMB
... also a query which list the OS of the VM's
Get-VM | Get-View -Property @("Name", "Guest.GuestFullName") | Select -Property Name, @{N="Running OS";E={$_.Guest.GuestFullName}}
But really I have no idea how to combine them to work in a single query,
Help please !
Thanks !
Try something like this.
It combines the pipeline and two Where-clauses
Get-VM | where{$_.ExtensionData.Guest.GuestFullName -match "Windows"} |
Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-3)} |
Select-Object VM, Name, Created, SizeMB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this.
It combines the pipeline and two Where-clauses
Get-VM | where{$_.ExtensionData.Guest.GuestFullName -match "Windows"} |
Get-Snapshot | Where {$_.Created -lt (Get-Date).AddDays(-3)} |
Select-Object VM, Name, Created, SizeMB
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Lucd, thanks ! works perfect !