Last active
February 26, 2018 18:37
-
-
Save Chirishman/c97ef3f18d0811faf68ae4d9628a1936 to your computer and use it in GitHub Desktop.
Install Registry Tweaks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
'HKLM:\SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'=@{ | |
'NoOpenWith'=@{ | |
Val='' | |
Type='String' | |
} | |
'NoStaticDefaultVerb'=@{ | |
Val='' | |
Type='String' | |
} | |
} | |
'HKLM:\SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9'=@{ | |
'NoOpenWith'=@{ | |
Val='' | |
Type='String' | |
} | |
'NoStaticDefaultVerb'=@{ | |
Val='' | |
Type='String' | |
} | |
} | |
'HKCU:\SOFTWARE\Classes\AppX4hxtad77fbk3jkkeerkrm0ze94wjf3s9'=@{ | |
'NoOpenWith'=@{ | |
Val='' | |
Type='String' | |
} | |
'NoStaticDefaultVerb'=@{ | |
Val='' | |
Type='String' | |
} | |
} | |
'HKCU:\SOFTWARE\Classes\AppXd4nrz8ff68srnhf9t5a8sbjyar1cr723'=@{ | |
'NoOpenWith'=@{ | |
Val='' | |
Type='String' | |
} | |
'NoStaticDefaultVerb'=@{ | |
Val='' | |
Type='String' | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Install-RegistryTweaks { | |
[CmdletBinding()] | |
Param ( | |
[Parameter(ValueFromPipeline=$True)] | |
[Alias('InputObject')] | |
[hashtable]$RegistryTweaks | |
) | |
$RegistryTweaks.GetEnumerator() | %{ | |
$path = $_.Key -split "\\" | |
if (-not (Test-Path $_.Key)){ | |
Write-Verbose "Key doesn't exist, beginning to recursively create subkeys" | |
0..($path.length - 1) | %{ | |
if (-not (Test-Path ($path[0..$_] -join "\"))){ | |
Write-Verbose "Creating subkey $($path[$_]) in $($path[0..($_-1)] -join "\")" | |
(get-item ($path[0..($_-2)] -join "\")).OpenSubKey($path[$_-1],$true).CreateSubKey($path[$_]) | |
} | |
} | |
} | |
Write-Verbose "Opening Target Key $($_.Key)" | |
$thisKey = (get-item ($path[0..($path.Length-2)] -join "\")).OpenSubKey($path[$path.Length-1],$true) | |
$_.Value.GetEnumerator() | % { | |
if (($thisKey.GetValue($_.Key) -eq $_.Value.Val)) { | |
Write-Verbose "Value $($_.Key) = $($_.Value.Val) value already set" | |
} else { | |
Write-Verbose "Writing Value $(($_.Key, $_.Value.Val, [Microsoft.Win32.RegistryValueKind]::($_.Value.Type)) -join ", ")" | |
$thisKey.SetValue($_.Key, $_.Value.Val, [Microsoft.Win32.RegistryValueKind]::($_.Value.Type)) | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[Breaking Change] - Changed to expect an input object with string values in the Type property instead of RegistryValueKinds. This allows storage of the objects in PSD1 files. PSD1 files don't support OrderedDictionary objects so I've removed that constraint. Usage now looks like: