Better output for AddRegKey()
This commit is contained in:
parent
5e9148b111
commit
00e4a21767
1 changed files with 22 additions and 22 deletions
|
@ -251,13 +251,12 @@ function AddRegKey {
|
||||||
}
|
}
|
||||||
|
|
||||||
#Let's begin...
|
#Let's begin...
|
||||||
Write-Host -NoNewline "`t$($params.path.substring(0,30))...$($params.key) reg key to $($params.value) : "
|
Write-Host -NoNewline "`t$($params.path.substring(0,30))...$($params.key) reg key to '$($params.value)' : "
|
||||||
if ( -not (Test-Path $params.path) ){
|
if ( -not (Test-Path $params.path) ){
|
||||||
Write-Host -NoNewline -ForegroundColor DarkGreen "creating path "
|
Write-Host -NoNewline -ForegroundColor DarkGreen "creating path "
|
||||||
try {
|
try {
|
||||||
New-Item -Path $params.path -Force | Out-Null
|
New-Item -Path $params.path -Force | Out-Null
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
Write-Host -NoNewLine -ForegroundColor Red "Error`n`t"
|
Write-Host -NoNewLine -ForegroundColor Red "Error`n`t"
|
||||||
Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||||
|
@ -268,11 +267,12 @@ 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 = "" }
|
||||||
if ( $current_value -eq $params.value ) {
|
if ( $current_value -eq $params.value ) {
|
||||||
Write-Host -ForegroundColor Yellow "Already done"
|
Write-Host -ForegroundColor Yellow "Already done"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
else { Write-Host -NoNewline -ForegroundColor DarkGreen "old value $current_value " }
|
else { Write-Host -NoNewline -ForegroundColor DarkGreen " old value $current_value - " }
|
||||||
}
|
}
|
||||||
catch {
|
catch {
|
||||||
Write-Host -NoNewline -ForegroundColor DarkGreen "new key "
|
Write-Host -NoNewline -ForegroundColor DarkGreen "new key "
|
||||||
|
|
Reference in a new issue