我看过一堆密切相关的帖子,所以我知道我并不孤单,但没有人给我我正在寻找的答案。如果有人问过并回答过这个问题而我找不到它,我深表歉意。
此脚本创建一个自定义通知区域气球,如果单击该气球,将打开一个指向某个 URL 的新 IE 窗口。在我一直在使用它的 PowerShell ISE GUI 中效果很好。无法使用我在其他帖子中看到的任何选项从命令行运行。具体来说,无法打开 IE 窗口。通知出现没有问题,但是没有IE窗口...??尝试过:
等等。
想法?
我的脚本:
#Load the required assemblies
[void] [System.Reflection.Assembly]::LoadWithPartialName(“System.Windows.Forms”)
#Remove any registered events related to notifications
Remove-Event BalloonClicked_event -ea SilentlyContinue
Unregister-Event -SourceIdentifier BalloonClicked_event -ea silentlycontinue
Remove-Event BalloonClosed_event -ea SilentlyContinue
Unregister-Event -SourceIdentifier BalloonClosed_event -ea silentlycontinue
Remove-Event Disposed -ea SilentlyContinue
Unregister-Event -SourceIdentifier Disposed -ea silentlycontinue
#Create the notification object
$notification = New-Object System.Windows.Forms.NotifyIcon
#Define various parts of the notification
$notification.Icon = …Run Code Online (Sandbox Code Playgroud) powershell notifications powershell-ise powershell-2.0 windows-7
获取 Event1 后,我需要获取在 Event1之后一段未知时间发生的另一个事件的第一个实例。然后获取在 Event2 之后某个时间发生的 Event3 等。
基本上从以下开始:
$filterXML = @'
<QueryList>
<Query Id="0" Path="System">
<Select Path="System">*[System[Provider[@Name='Microsoft-Windows-Kernel-General'] and (Level=4 or Level=0) and (EventID=12)]]</Select>
</Query>
</QueryList>
'@
$event1=(Get-WinEvent -ComputerName $PCname -MaxEvents 1 -FilterXml $filterXML).timecreated
Run Code Online (Sandbox Code Playgroud)
给我 Event1 的日期时间。然后我想做类似的事情:
Get-WinEvent -LogName "System" -MaxEvents 1 -FilterXPath "*[EventData[Data = 'Windows Management Instrumentation' and TimeCreated -gt $event1 ]]"
显然,时间创建的粗体部分不起作用,但我希望你明白我想要做的事情。有什么帮助吗?
我想也许filterhashtable就是我需要走的路?寻求澄清:
$Event2=(Get-WinEvent -Oldest -MaxEvents 1 -FilterHashtable @{logname="system"; providername="Microsoft-Windows-GroupPolicy"; starttime=$Event1}).TimeCreated
Run Code Online (Sandbox Code Playgroud)