ci(lint): add CmdletBinding and ShouldProcess support to ISO creation functions for safer execution

This commit is contained in:
Simone
2026-05-13 19:11:33 +02:00
committed by Simone
parent 2ac26dbd00
commit 3f05e89362
3 changed files with 24 additions and 0 deletions
+4
View File
@@ -242,11 +242,13 @@ if (-not ([System.Management.Automation.PSTypeName]'IsoStreamWriter2').Type) {
}
function New-IsoFromFolder {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Low')]
param(
[Parameter(Mandatory)] [string] $SourceFolder,
[Parameter(Mandatory)] [string] $IsoPath,
[Parameter(Mandatory)] [string] $VolumeLabel
)
if (-not $PSCmdlet.ShouldProcess($IsoPath, 'Create ISO from folder')) { return }
if (Test-Path $IsoPath) { Remove-Item $IsoPath -Force }
$fsi = New-Object -ComObject IMAPI2FS.MsftFileSystemImage
$result = $null
@@ -296,11 +298,13 @@ function Invoke-Vmrun {
}
function Set-VmxKey {
[CmdletBinding(SupportsShouldProcess, ConfirmImpact='Low')]
param(
[Parameter(Mandatory)] [string] $VmxPath,
[Parameter(Mandatory)] [string] $Key,
[Parameter(Mandatory)] [string] $Value
)
if (-not $PSCmdlet.ShouldProcess($VmxPath, "Set VMX key '$Key'")) { return }
$lines = Get-Content -LiteralPath $VmxPath
$pattern = "^\s*$([regex]::Escape($Key))\s*="
$found = $false