26 lines
710 B
PowerShell
26 lines
710 B
PowerShell
|
function Set-RegistryValue {
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Sets a registry key to a specific value
|
||
|
#>
|
||
|
[CmdletBinding()]
|
||
|
[OutputType([System.Boolean])]
|
||
|
param(
|
||
|
[string]$registryPath,
|
||
|
[string]$keyName,
|
||
|
[string]$desiredValue
|
||
|
)
|
||
|
|
||
|
$logLead = (Get-LogLeadName);
|
||
|
$itemProp = Get-ItemProperty -Path $registryPath -Name $keyName
|
||
|
|
||
|
if ($itemProp.$keyName -eq $desiredValue) {
|
||
|
Write-Host ("$logLead : The $keyName value is already set to $desiredValue -- no changes required")
|
||
|
return $false
|
||
|
}
|
||
|
|
||
|
Write-Host ("$logLead : Setting the $keyName Value to $desiredValue")
|
||
|
Set-ItemProperty -Path $registryPath -Name $keyName -Value $desiredValue
|
||
|
return $true
|
||
|
}
|