# 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: 1948
# x-archived: 2013-11-14T21:43:29
# x-published: 2010-07-07T08:23:00
#
#
# Roll-Dice.ps1
# Cody Bunch
# ProfessionalVMware.com

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

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