Automation

 View Only
Expand all | Collapse all

Snapshots older then 3 days on specific OS type

  • 1.  Snapshots older then 3 days on specific OS type

    Posted Jan 19, 2018 01:17 PM

    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 !



  • 2.  RE: Snapshots older then 3 days on specific OS type
    Best Answer

    Posted Jan 19, 2018 01:28 PM

    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



  • 3.  RE: Snapshots older then 3 days on specific OS type

    Posted Jan 19, 2018 01:50 PM

    Lucd, thanks ! works perfect !