-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy path1079.ps1
More file actions
32 lines (29 loc) · 1016 Bytes
/
Copy path1079.ps1
File metadata and controls
32 lines (29 loc) · 1016 Bytes
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
# In order to enumerate all the WMI namespaces, you must first connect to the "root" namespace,
# query for all the "__NAMESPACE" instances, and for each instance recursively repeat this process.
# You can use the computerName parameter of Get-WmiNamespace to list the WMI namespaces on the remote computer.
function Get-WmiNamespace {
param (
[string]$rootns = "root",
[string]$computerName = ".",
$credential
)
if ($credential -is [String] ) {
$credential = Get-Credential $credential
}
if ($credential -eq $null) {
gwmi -class __namespace -namespace $rootns -computerName $computerName |
where {$_.name} | foreach {
$ns = "{0}\{1}" -f $rootns,$_.name
$ns
Get-WmiNamespace -rootns $ns -computer $computerName
}
}
else {
gwmi -class __namespace -namespace $rootns -computerName $computerName -credential $credential |
where {$_.name} | foreach {
$ns = "{0}\{1}" -f $rootns,$_.name
$ns
Get-WmiNamespace -rootns $ns -computer $computerName -credential $credential
}
}
}