PoshCode Archive  Artifact [c17f5ece54]

Artifact c17f5ece54e4a1e653eed89ddc727df53f0165a475fc0f61e99adb04d2596e6f:

  • File Roll-Dice.ps1 — part of check-in [b7a84f19df] at 2018-06-10 13:03:17 on branch trunk — A really bad roll-dice script to do ‘bad things’ to vmware snapshots taken on the pipeline. (user: Cody Bunch size: 733)

# encoding: ascii
# api: powershell
# title: Roll-Dice.ps1
# description: A really bad roll-dice script to do ‘bad things’ to vmware snapshots taken on the pipeline.
# version: 0.1
# author: Cody Bunch
# license: CC0
# x-poshcode-id: 1953
# x-archived: 2013-11-15T09:16:02
# x-published: 2010-07-07T11:28:00
#
#
# Roll-Dice.ps1
# Cody Bunch
# ProfessionalVMware.com

Begin {
	$rand = New-Object System.Random
	$dice = $rand.next(1,4)
}

Process {
	if ( $_ -isnot [VMware.VimAutomation.Types.Snapshot] ) { continue }
	if ($dice -gt 1) { 
		$_ | Remove-Snapshot -Confirm:$false
		Write-Host "OH NOES! Snapshot $_ Has been deleted!`n" 
	} else {
		Write-Host "Snapshot $_ lives to fight again!`n"
	}
}