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...
|
||||
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) ){
|
||||
Write-Host -NoNewline -ForegroundColor DarkGreen "creating path "
|
||||
try {
|
||||
New-Item -Path $params.path -Force | Out-Null
|
||||
}
|
||||
|
||||
catch {
|
||||
Write-Host -NoNewLine -ForegroundColor Red "Error`n`t"
|
||||
Write-Host -ForegroundColor DarkRed $Error[0].Exception.Message
|
||||
|
@ -268,11 +267,12 @@ function AddRegKey {
|
|||
# Test if the key already exist
|
||||
try {
|
||||
$current_value = Get-ItemPropertyValue -Path $params.path -Name $params.key
|
||||
if ( -not $current_value ) { $current_value = "" }
|
||||
if ( $current_value -eq $params.value ) {
|
||||
Write-Host -ForegroundColor Yellow "Already done"
|
||||
return
|
||||
}
|
||||
else { Write-Host -NoNewline -ForegroundColor DarkGreen "old value $current_value " }
|
||||
else { Write-Host -NoNewline -ForegroundColor DarkGreen " old value $current_value - " }
|
||||
}
|
||||
catch {
|
||||
Write-Host -NoNewline -ForegroundColor DarkGreen "new key "
|
||||
|
|
Reference in a new issue