ci(lint): add CmdletBinding and ShouldProcess support to ISO creation functions for safer execution
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user