VMware Cloud Community
mpolok
Contributor
Contributor
Jump to solution

Snapshots older then 3 days on specific OS type

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 !

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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

0 Kudos
mpolok
Contributor
Contributor
Jump to solution

Lucd, thanks ! works perfect !

0 Kudos