Last active
July 28, 2016 09:25
-
-
Save aetos382/9d87b64111b94be8ff15e17b8f7e15b7 to your computer and use it in GitHub Desktop.
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
# This query is valid. __InstanceCreationEvent class has TargetInstance property. | |
$query = @' | |
SELECT * FROM __InstanceCreationEvent WITHIN 1 WHERE TargetInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe' | |
'@ | |
$evt = Register-CimIndicationEvent -Query $query -SourceIdentifier 'TestEvent' -Action { | |
$EventArgs | Get-Member -Force | Out-Default | |
$EventArgs | Format-List * | Out-Default | |
$e = $EventArgs.NewEvent | |
$e | Get-Member -Force | Out-Default | |
$e | Format-List * | Out-Default | |
$instance = $e.TargetInstance | |
$instance | Get-Member -Force | Out-Default | |
$instance | Format-List * | Out-Default | |
} | |
$evt | |
# Unregister-Event -SourceIdentifier 'TestEvent' |
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
# This query is invalid. Why? CIM_InstCreation has SourceInstance property. | |
$query = @' | |
SELECT * FROM CIM_InstCreation WITHIN 1 WHERE SourceInstance ISA 'Win32_Process' AND SourceInstance.Name = 'cmd.exe' | |
'@ | |
$evt = Register-CimIndicationEvent -Query $query -SourceIdentifier 'TestEvent' -Action { | |
$EventArgs | Get-Member -Force | Out-Default | |
$EventArgs | Format-List * | Out-Default | |
$e = $EventArgs.NewEvent | |
$e | Get-Member -Force | Out-Default | |
$e | Format-List * | Out-Default | |
$instance = $e.SourceInstance | |
$instance | Get-Member -Force | Out-Default | |
$instance | Format-List * | Out-Default | |
} | |
$evt | |
# Unregister-Event -SourceIdentifier 'TestEvent' |
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
# This query is valid. Why? CIM_InstCreation class doesn't have TargetInstance property. | |
$query = @' | |
SELECT * FROM CIM_InstCreation WITHIN 1 WHERE SourceInstance ISA 'Win32_Process' AND TargetInstance.Name = 'cmd.exe' | |
'@ | |
$evt = Register-CimIndicationEvent -Query $query -SourceIdentifier 'TestEvent' -Action { | |
$EventArgs | Get-Member -Force | Out-Default | |
$EventArgs | Format-List * | Out-Default | |
$e = $EventArgs.NewEvent | |
$e | Get-Member -Force | Out-Default | |
$e | Format-List * | Out-Default | |
$instance = $e.SourceInstance | |
$instance | Get-Member -Force | Out-Default | |
$instance | Format-List * | Out-Default | |
} | |
$evt | |
# Unregister-Event -SourceIdentifier 'TestEvent' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment