mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-12-28 01:28:50 +01:00
Add upload-to-discord.ps1
This commit is contained in:
parent
8fb66ad7eb
commit
e14f126f4c
22
Scripts/upload-to-discord.ps1
Normal file
22
Scripts/upload-to-discord.ps1
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
function Upload-Discord {
|
||||||
|
|
||||||
|
[CmdletBinding()]
|
||||||
|
param (
|
||||||
|
[parameter(Position=0,Mandatory=$False)]
|
||||||
|
[string]$file,
|
||||||
|
[parameter(Position=1,Mandatory=$False)]
|
||||||
|
[string]$text
|
||||||
|
)
|
||||||
|
|
||||||
|
$hookurl = 'YOUR-DISCORD-WEBHOOK'
|
||||||
|
|
||||||
|
$Body = @{
|
||||||
|
'username' = $env:username
|
||||||
|
'content' = $text
|
||||||
|
}
|
||||||
|
|
||||||
|
if (-not ([string]::IsNullOrEmpty($text))){
|
||||||
|
Invoke-RestMethod -ContentType 'Application/Json' -Uri $hookurl -Method Post -Body ($Body | ConvertTo-Json)};
|
||||||
|
|
||||||
|
if (-not ([string]::IsNullOrEmpty($file))){curl.exe -F "file1=@$file" $hookurl}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user