Update tiny11maker.ps1 - error handling param

error handling for param as we will later make the script agnostic to execution on OSDrive / $env:systemdrive
This commit is contained in:
Karl Wester-Ebbinghaus 2024-11-07 02:07:18 +01:00 committed by GitHub
parent a5a4d97994
commit 5ca27c740e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,11 +29,19 @@ if (! $myWindowsPrincipal.IsInRole($adminRole))
exit exit
} }
param ($ScratchDisk) param (
if ($Null -eq $ScratchDisk) { [ValidatePattern('^[c-zC-Z]$')]
$ScratchDisk = $env:SystemDrive [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 the transcript and prepare the window
Start-Transcript -Path "$PSScriptRoot\tiny11.log" Start-Transcript -Path "$PSScriptRoot\tiny11.log"