From 92bd7ba69f796751788694b13c379ca1fc5e5677 Mon Sep 17 00:00:00 2001 From: lksz Date: Sat, 8 May 2021 17:48:32 -0400 Subject: [PATCH] Added haste module with New-Haste cmdlet --- hastebin/New-Haste.ps1 | 24 ++++++++++++++++++++++++ hastebin/_.package.json | 6 ++++++ 2 files changed, 30 insertions(+) create mode 100644 hastebin/New-Haste.ps1 create mode 100644 hastebin/_.package.json diff --git a/hastebin/New-Haste.ps1 b/hastebin/New-Haste.ps1 new file mode 100644 index 0000000..1aa3d74 --- /dev/null +++ b/hastebin/New-Haste.ps1 @@ -0,0 +1,24 @@ +[CmdletBinding()]param( + [Parameter(ValueFromPipeline,Mandatory,Position=1)] + $InputObject +) +begin { + $data = @() +} + +process { + $data += $InputObject +} + +end { + if( -not $HastebinBase ) { $HastebinBase = "https://h.lksz.me" } + $URI = "$HastebinBase/documents" + $Body = ($dataArray | Out-String).TrimEnd() + + $Response = Invoke-RestMethod -Method Post -Body $Body -Uri $URI + $key = $Response.key + + $hasteAddress = "$HastebinBase/$key" + + return $hasteAddress +} diff --git a/hastebin/_.package.json b/hastebin/_.package.json new file mode 100644 index 0000000..69f7cf4 --- /dev/null +++ b/hastebin/_.package.json @@ -0,0 +1,6 @@ +{ + "package": { + "Condition": [], + "Name": "hastebin" + } +}