Microsoft团队从JSON有效负载读取时会截断文本

时间:2019-12-30 21:51:07

标签: json powershell

我有一个Power Shell脚本,当网站关闭时,该脚本会自动向Microsoft Teams发送消息。现在,它切断了网站的名称。有没有办法以可点击的超链接形式显示整个网站。我包括用于生成在团队中显示的JSON有效负载的代码。 Screenshot of Window

$webhookurl = "Webhook Goes here"
$json = New-Object PSCustomObject



function Generate-JsonPayload {
    Param(
        [String] $summary,
        [String] $title,
        [string] $text,
        [string] $facts
    )
    $date = "$(Get-Date -Format g) UTC"
    @"
{
    "@type": "MessageCard",
    "@context": "https://schema.org/extensions",
    "summary": "$($summary)",
    "themeColor": "ffe600",
    "title": "$($summary)",
    "sections": [
        {
            "activityTitle": "$($title)",
            "activitySubtitle": "$($date)",
            "text": "$($text)",
            "facts": $facts
        }
    ]
}
"@

}
<# Import the Log CSV File Put it into $CSVImport Vatiable#>
$CSVImport = Import-Csv -Path "C:\pathname_here" -Header "Timestamp", "Status", "URL" | where {$_.Status -eq "Fail"} | Where-Object { [datetime]$_.Timestamp -gt (Get-Date).Addminutes(-25)}   
<#$CsvFails = [pscustomobject]$CSVImport#>


if ($CSVImport) {

    $facts1 = ConvertTo-Json -Inputobject @( foreach($f in $CSVImport) {
        [PSCustomObject]@{
            Name = $f.Url
            Value = "$($f.Timestamp) | $(($f.Status))"
        }
    })

    $splat = @{
        Summary = "Website Checker"
        Title = "These Websites Are Down!"
        Text = "Please Check these Websites"
        Facts = $facts1
    }


    $json = Generate-JsonPayload @splat

    Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body $json -Uri $webhookurl
}

0 个答案:

没有答案