# 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: 1952
# x-derived-from-id: 1953
# x-archived: 2017-02-12T10:05:22
# x-published: 2011-07-07T10:35:00
#
#
# Roll-Dice.ps1
# Cody Bunch
# ProfessionalVMware.com

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

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