使用PowerShell开发RSS新闻警报的通知

问题描述 投票:0回答:2

我有此基本代码,适用于简单的短信提醒。现在,只要我们的ITS警报系统中有新的RSS提要,连接此脚本即可向用户发出警报。

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
 $objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
 $objNotifyIcon.Icon = [System.Drawing.SystemIcons]::Information
 $objNotifyIcon.BalloonTipIcon = "Info"
 $text = 'This is just a text'
 $objNotifyIcon.BalloonTipText = $text
 $objNotifyIcon.BalloonTipTitle = "Tip Title"
 $objNotifyIcon.Visible = $True
 $objNotifyIcon.ShowBalloonTip(30000)
powershell rss
2个回答
0
投票

我认为您必须将此新警报与RSS提要的某些解析结合起来,这是一个很好的资源,可以详细了解此Use PowerShell to Parse RSS Feeds


0
投票

这里是自动关闭的想法:

Function Get-BalloonTip {
    [CmdletBinding()]
    Param (
    [Parameter(Mandatory=$true)]$Text,
    [Parameter(Mandatory=$true)]$Title,
    $Icon = 'Info',
    $Timeout = $10000
             )
    Process {
    Add-Type -AssemblyName System.Windows.Forms
    If ($PopUp -eq $null)  {
           $PopUp = New-Object System.Windows.Forms.NotifyIcon
                        }
             $Path = Get-Process -Id $PID | Select-Object -ExpandProperty Path
             $PopUp.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($Path)
             $PopUp.BalloonTipIcon = $Icon
             $PopUp.BalloonTipText = $Text
             $PopUp.BalloonTipTitle = $Title
             $PopUp.Visible = $true
             $PopUp.ShowBalloonTip($Timeout)
             Start-Sleep 5
             $PopUp.Visible = $false
                     } # End of Process
    } # End of Function

    Get-BalloonTip -Text "Hello" "Check This out" 
© www.soinside.com 2019 - 2024. All rights reserved.