Test if registry key value is null of empty in AddRegKey()
This commit is contained in:
parent
00e4a21767
commit
e2fe868454
1 changed files with 4 additions and 4 deletions
|
@ -225,7 +225,7 @@ function AddRegKey {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if ( -not $params.ContainsKey('value') ) {
|
if ( -not $params.ContainsKey('value') ) {
|
||||||
$params.value = ""
|
$params.value = $null
|
||||||
}
|
}
|
||||||
if ( -not $params.ContainsKey('type') -or $params.type -eq "" ){ $params.type="DWord" }
|
if ( -not $params.ContainsKey('type') -or $params.type -eq "" ){ $params.type="DWord" }
|
||||||
|
|
||||||
|
@ -266,9 +266,9 @@ function AddRegKey {
|
||||||
|
|
||||||
# Test if the key already exist
|
# Test if the key already exist
|
||||||
try {
|
try {
|
||||||
$current_value = Get-ItemPropertyValue -Path $params.path -Name $params.key
|
$current_value = (Get-ItemPropertyValue -Path $params.path -Name $params.key)
|
||||||
if ( -not $current_value ) { $current_value = "" }
|
#current_value and params.value both empty need a special condition
|
||||||
if ( $current_value -eq $params.value ) {
|
if ( ( [string]::IsNullOrWhitespace($current_value) -and [string]::IsNullOrWhitespace($params.value) ) -or ($current_value -eq $params.value) ) {
|
||||||
Write-Host -ForegroundColor Yellow "Already done"
|
Write-Host -ForegroundColor Yellow "Already done"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue