From 356e2d898c7e0426cfd31a1085ad8709419a8ac8 Mon Sep 17 00:00:00 2001 From: emersonbusson <93008583+emersonbusson@users.noreply.github.com> Date: Fri, 18 Sep 2026 09:13:46 +0000 Subject: [PATCH] fix: add CmdletBinding and guard clauses to Run-GuestExhaustive.ps1 --- scripts/windows/Run-GuestExhaustive.ps1 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/windows/Run-GuestExhaustive.ps1 b/scripts/windows/Run-GuestExhaustive.ps1 index ba62baaa7..1fdca0a6a 100755 --- a/scripts/windows/Run-GuestExhaustive.ps1 +++ b/scripts/windows/Run-GuestExhaustive.ps1 @@ -11,6 +11,9 @@ #> [CmdletBinding()] param( + [Parameter(Mandatory = $false)] + [ValidateSet("win11-drill", "win11-drill-baseline")] + [ValidateNotNullOrEmpty()] [string]$VMName = "win11-drill", [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] @@ -64,6 +67,13 @@ param( Set-StrictMode -Version Latest $ErrorActionPreference = "Stop" +if (-not (Get-Module -ListAvailable -Name Hyper-V)) { + throw [System.InvalidOperationException]::new("Hyper-V module is not available") +} +if (-not (Get-VM -Name $VMName -ErrorAction SilentlyContinue)) { + throw [System.IO.FileNotFoundException]::new("VM '$VMName' does not exist") +} + . (Join-Path $PSScriptRoot "Invoke-GuestPsDirectBounded.ps1") function Normalize-GuestVerifierSha256 {