Repository navigation
Expand file tree
/
Copy pathRegistryHelper.ps1
More file actions
129 lines (90 loc) · 2.69 KB
/
Copy pathRegistryHelper.ps1
File metadata and controls
129 lines (90 loc) · 2.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#wmi functions wrapped in powershell. WMI is on by default and is a lot faster than winrm
#HKLM = 2147483650
Function Connect-ToRemoteRegistry{
try{
[Object]$WMIREGISTRYOBJ = Get-WmiObject -List -NameSpace root\default -ComputerName $strComputer | Where-Object {$_.Name -eq "StdRegProv"}
}catch{
}
return $WMIREGISTRYOBJ
}
Function Assert-RegAccess{
param(
[string]$strKey,
[wmiObject]$oWMIRegistry
)
$strKeyPath = "SYSTEM\CurrentControlSet"
$bHasAccessRight = $oWMIRegistry.CheckAccess($rootIdentifier, $strKeyPath," KEY_QUERY_VALUE")
if ($bHasAccessRight -ne $True){
Write-Host "You do not have access, run script as admin"
}else{
return $bHasAccessRight
}
}
#Returns String, Finds key values in Registry, ONLY for REG_SZ type(string)
Function Get-RegistryREG_SZ{
param(
[string]$strKeyPath,
[string]$strKey,
[wmiObject]$oWMIRegistry,
[uint32]$rootIdentifier = 2147483650
)
$strKeyValue = $oWMIRegistry.GetStringValue($rootIdentifier,$strKeyPath,$strKey).sValue
return $strKeyValue
}
#Returns String, Find key values in Registry, Only for REG_MULTI_SZ(arrays)
Function Get-RegistryMulti {
param(
[string]$strKeyPath,
[string]$strKey,
[wmiObject]$oWMIRegistry,
[uint32]$rootIdentifier = 2147483650
)
$arrKeyValue = @()
$arrKeyValue = $oWMIRegistry.GetMultiStringValue($rootIdentifier,$strKeyPath,$strKey).sValue
return $arrKeyValue
}
#Returns String, Find key values in Registry, Only for DWORD, Returns human readable value
Function Get-RegistryDWord {
param(
[string]$strKeypath,
[string]$strKey,
[wmiObject]$oWMIRegistry,
[uint32]$rootIdentifier = 2147483650
)
$strKeyValue = $oWMIRegistry.GetDWORDValue($rootIdentifier,$strKeyPath,$strKey).uValue
return $strKeyValue
}
Function Get-AllKeysInSubKey {
param(
[string]$strKeyPath,
[wmiObject]$oWMIRegistry,
[uint32]$rootIdentifier = 2147483650
)
try{
$arrSubKeys = $oWMIRegistry.EnumKey($rootIdentifier, $strKeyPath)
}catch{
}
return $arrSubKeys
}
Function Get-AllKeyValuePairsInSubkey{
}
Function Get-ValuesOfOneKey{
}
Function Get-KeyValuePair{}
Function Search-RegForKey{}
Function Search-RegForValue{}
Function Write-key{}
Function Remove-Key{}
Function Assert-KeyExists{
param(
[string]$strKeyPath,
[string]$strKeyName,
[uint32]$rootIdentifier = 2147483650
)
$keyLocation = [io.path]::Combine("HKLM:",$strKeyPath, $strKeyName)
if ((Test-Path $keyLocation) -ne $false){
return $true
}else{
return $false
}
}