Function Send-Chat{ Param( [string] $Msg ) Add-Type -AssemblyName System.Web $url = "http://your ip:port/webapi/entry.cgi?api=SYNO.Chat.External&method=incoming&version=2&token=%22el3fotmx3xHbiXGz17aTTXFUJ5DTzgun6bwhLA5bfqso%22" $json = 'payload={{"text": "{0}"}}' -f [System.Web.HttpUtility]::UrlEncode($Msg) Try{ $Response = Invoke-WebRequest -Uri $url -Method POST -Body $json }Catch [exception]{ ...