From 5ca27c740e325c042a00a29e21ba11a43e291558 Mon Sep 17 00:00:00 2001 From: Karl Wester-Ebbinghaus <45657752+Karl-WE@users.noreply.github.com> Date: Thu, 7 Nov 2024 02:07:18 +0100 Subject: [PATCH] Update tiny11maker.ps1 - error handling param error handling for param as we will later make the script agnostic to execution on OSDrive / $env:systemdrive --- tiny11maker.ps1 | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tiny11maker.ps1 b/tiny11maker.ps1 index 64f215b..fe01824 100644 --- a/tiny11maker.ps1 +++ b/tiny11maker.ps1 @@ -29,11 +29,19 @@ if (! $myWindowsPrincipal.IsInRole($adminRole)) exit } -param ($ScratchDisk) -if ($Null -eq $ScratchDisk) { - $ScratchDisk = $env:SystemDrive +param ( + [ValidatePattern('^[c-zC-Z]$')] + [string]$ScratchDisk +) + +if (-not $ScratchDisk) { + $ScratchDisk = $PSScriptRoot -replace '[\\]+$', '' +} else { + $ScratchDisk = $ScratchDisk + ":" } +Write-Output "Scratch disk set to $ScratchDisk" + # Start the transcript and prepare the window Start-Transcript -Path "$PSScriptRoot\tiny11.log"