PoshCode Archive  Artifact Content

Artifact fb5a1369b748d839be8cc726ca6970cf64312ece8ffe44e10f8908aa93e8f71b:

  • File Roll-Dice.ps1 — part of check-in [d45b1f1071] at 2018-06-10 13:03:12 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: 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"
	}
}