Exclusive look at a 2-in-1 query over a function I'm writing
function Set-SystemSound {
param (
[Parameter(Mandatory)]
[string]$EventKey,
[Parameter(Mandatory)]
[string]$SoundPath,
[string]$Scheme
)
$EventKey = "HKCU:\AppEvents\Schemes\Apps\$EventKey"
Set-ItemProperty -Path "$EventKey\.Current" -Name '(Default)' -Value $SoundPath
if($Scheme) {
Set-ItemProperty -Path "$EventKey\$Scheme" -Name '(Default)' -Value $SoundPath
}
}```The points:
- Will that `if($Scheme)` boolean check work as expected? I want it to return false if the user didn't enter anything for it
- Is the way I'm manipulating `$EventKey` at the start "proper"?
- Does it look alright in general?