Last active
May 27, 2017 01:26
-
-
Save et0x/7049545a3022879f7bffa3e4e44eeb6b to your computer and use it in GitHub Desktop.
List all WMI extrinsic event classes recursively
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 Get-Derived { | |
Param( | |
[String]$Class, | |
[String]$Namespace | |
) | |
if (-not [string]::IsNullOrEmpty($Class)) | |
{ | |
Get-WmiObject -List -Namespace $Namespace | Where-Object { $_.__SUPERCLASS -eq $Class -and (-not ($_.Name.StartsWith('__')) ) } | foreach { | |
Get-Derived -Class $_.__CLASS -Namespace $_.__NAMESPACE | |
$_ | |
} | |
} | |
} | |
function Get-ExtrinsicEvents | |
{ | |
$namespaces = Get-WmiObject -Namespace 'root' -Class '__Namespace' -Recurse | Select-Object @{N='Name';E={"root/$($_.Name)"}} | |
$extrinsic = $namespaces.Name | foreach { $ns = $_; Get-WmiObject -List -namespace $_ | Where-Object { ($_.__SUPERCLASS -eq '__ExtrinsicEvent') -and -not ( ($_.Name).StartsWith('__')) } } | |
$extrinsic | foreach { | |
$_ | |
Get-Derived -Class ($_.Name) -Namespace ($_.__NAMESPACE) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment