2
對不起,英語不好。Powershell事件轉發
我在PowerShell和事件轉發機制中有一些麻煩。我試着這樣做:
$remoteComputer = "."
$session = New-PsSession $remoteComputer
Unregister-Event CatchEvent -ErrorAction SilentlyContinue
Invoke-Command $session {
## The WMI query to detect a stopping service
$query = @"
SELECT *
FROM __instancecreationevent
WHERE TargetInstance ISA 'Win32_NtLogEvent'
and targetinstance.eventcode = '7036'
"@
Register-WmiEvent -Query $query "CatchEvent" -Forward
}
$null = Register-EngineEvent CatchEvent -Action { $GLOBAL:MyEvent = $event}
$ MyEvent變量最後含有不是一個事件的信息,但System.String類的數據。 alt text http://eosfor.fileave.com/powershell.png
這個腳本怎麼了?