PoshCode Archive  Artifact [ee82217ed8]

Artifact ee82217ed8a8a45af0e69000376e5fe8580d404ad6b8cc58a27554ee7fbaa350:

  • File Bier.ps1 — part of check-in [2122747fb6] at 2018-06-10 14:00:23 on branch trunk — Simple PowerCLI example to find old snapshots. Note that I would not actually use the techniques shown here, this script was intentionally written this way as a part of a training video in which I am building on techniques. (user: Ridouan size: 794)

# encoding: ascii
# api: powershell
# title: Bier
# description: Simple PowerCLI example to find old snapshots. Note that I would not actually use the techniques shown here, this script was intentionally written this way as a part of a training video in which I am building on techniques.
# version: 0.1
# author: Ridouan
# license: CC0
# x-poshcode-id: 5738
# x-archived: 2015-05-17T02:49:12
# x-published: 2015-02-15T19:20:00
#
#
param ( $Age = 30 )

Connect-VIServer vcenter.domain.com
$vm = Get-VM
$snapshots = Get-Snapshot -VM $vm
Write-Host -ForegroundColor Red "Old snapshots found:"
foreach ( $snap in $snapshots ) {
	if ( $snap.Created -lt (Get-Date).AddDays( -$Age ) ) {
		Write-Host "Name: " $snap.Name "  Size: " $snap.SizeMB "  Created: " $snap.Created
	}
}