Add ErrorAction Stop for Get-ItemProperty in DelRegKey()

This commit is contained in:
Yorick Barbanneau 2018-04-11 23:08:20 +02:00
parent 37bb194595
commit 10eecf17f5

View file

@ -319,14 +319,13 @@ function DelRegKey {
return
}
try {
Get-ItemProperty -Path $params.path -Name $params.key | Out-Null
Get-ItemProperty -Path $params.path -Name $params.key -ErrorAction Stop | Out-Null
}
catch {
Write-Host -ForegroundColor Yellow "key already deleted"
Write-Host -ForegroundColor Yellow "key not exist (already deleted?)"
return
}
try {
Remove-ItemProperty -Path $params.path -Name $params.key
Write-host -ForegroundColor Green "done"
}