Skip to content

Commit 1b2c313

Browse files
committed
New registery example
1 parent e0d7556 commit 1b2c313

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
$regKeyPaths = @(
2+
"Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\Windows Defender",
3+
'Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System',
4+
'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CI\Config'
5+
)
6+
$iterCount = 0
7+
# Loop through each registry path
8+
$query = @( foreach ($regPath in $regKeyPaths) {
9+
$result = [ordered]@{
10+
Iter = ($IterCount++)
11+
HasError = $false
12+
NoProps = $true
13+
NoValues = $true
14+
Path = $RegPath
15+
}
16+
try {
17+
$result.ItemProps = Get-ItemProperty -Path $regPath
18+
$result.Values = $result.ItemProps |
19+
Select-Object -ExcludeProperty PSPath, PSParentPath, PSChildName, PSProvider
20+
} catch {
21+
$result.HasError = $true
22+
} finally {
23+
$result.NoProps = $result.ItemProps.Count -eq 0
24+
$result.NoValues = $result.Values.Count -eq 0
25+
[pscustomobject]$result
26+
}
27+
})
28+
29+
$query|Ft -auto
30+
$Query.count
31+
32+
# then you can drill down into individual queries
33+
$Query[0]

0 commit comments

Comments
 (0)