ВЗ
Size: a a a
ВЗ
D
ВК
ВЗ
param(
[Parameter(
Mandatory = $true,
Position = 0,
ValueFromPipeline = $true)]
[Alias("Id")]
[guid]$AlertId,
[Parameter(
Mandatory = $true,
Position = 1,
ValueFromPipeline = $false)]
[uri]$WebConsoleUrl,
[Parameter(
Mandatory = $true,
Position = 2)]
[uri]$TeamsUrl
)
begin
{
Import-Module -Name OperationsManager
New-SCOMManagementGroupConnection
}
process
{
$Alert = Get-SCOMAlert -Id $AlertId
if ($null -ne $Alert)
{
$WebConsoleLink = New-Object Uri($WebConsoleUrl, "/#/monitoring/drilldown/alert/{0:B}" -f $AlertId)
$Body = @"
{
"@type": "MessageCard",
"title": "$($Alert.Name.Replace("`'", "`""))",
"text": "Status: $($Alert.ResolutionState.ToString())",
"themeColor": "FF0000",
"sections": [{
"facts": [{
"name": "Time:",
"value": "$($Alert.LastModified)"
}, {
"name": "Source:",
"value": "$($Alert.MonitoringObjectDisplayName)"
}, {
"name": "Description:",
"value": "$($Alert.Description.Replace("\n", "`n"))"
}],
"markdown": true
}],
"potentialAction": [
{
"@type": "OpenUri",
"name": "Open WebConsole",
"targets": [{
"os": "default",
"uri": "$($WebConsoleLink.AbsoluteUri)"
}]
},
]
}
"@
Invoke-WebRequest -Uri $TeamsUrl -Method POST -Body $Body -ContentType "application/json"
}
}
end
{
Get-SCOMManagementGroupConnection | Remove-SCOMManagementGroupConnection
}
D
ВК
ВЗ
ВЗ
ВЗ
Get-Alert | Select -First 5 | .\ScriptName.ps1 -WebConsoleUrl https://.../... -TeamsUrl https://.../...
ВЗ
ВК
ВК
ВЗ
ВЗ
ВЗ
ВЗ
И
ВЗ
И
ВЗ