$file = Get-Content -Path "C:\1.txt"
$uri = "https://api.telegram.org/botXXXX/sendDocument?chat_id=XXXXX&document"
Invoke-RestMethod -Method Post -Uri $uri -ContentType 'multipart/form-data' -Body [byte]$file
$token = "ХХХХХХХХХХХ"
$chat_id = "ХХХХХХХХХ"
$uri = "https://api.telegram.org/bot$Token/sendDocument"
$fileObject= get-item C:\test\1.pdf
$Form = @{
chat_id = $Chat_ID
document = $fileObject
}#form
$invokeRestMethodSplat = @{
Uri = $Uri
ErrorAction = 'Stop'
Form = $Form
Method = 'Post'
}
Invoke-RestMethod @invokeRestMethodSplat