PoshCode Archive  Artifact Content

Artifact 83cea9e6b13042a86e0b5df6aef66c826f2499692b68a1811dc7b49eec512f10:

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

# 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"
	}
}