Quantcast
Channel: ISE Addons – Ravikanth Chaganti
Viewing all articles
Browse latest Browse all 34

Send content to PasteBin using PowerShell

$
0
0
PasteBin.com is a good way to share scripts with others. Over there, you can just paste scripts written in almost any language and select the language for syntax highlighting. The interesting part here is that they provide an API to do that. Like anything else that got an API, this one can also be scripted using PowerShell. So, here is a simple module that lets you paste content to PasteBin using PowerShell.          Function Test-Proxy { $webclient = New-Object System.Net.WebClient return $webclient.Proxy.IsBypassed("http://www.microsoft.com") } function New-PasteBin { [CmdletBinding()] param ( [Parameter(Mandatory=$True)] [String]$pasteCode, [Parameter(Mandatory=$False)] [String]$pasteName, [Parameter(Mandatory=$false)] [String]$pasteEmail, [Parameter(Mandatory=$false)] [String]$pasteSubDomain, [Parameter(Mandatory=$false)] [Switch]$pastePrivate, [Parameter(Mandatory=$False)] [ValidateSet("N", "10M", "1H", "1D", "1M")] [String]$pasteExpireDate, [Parameter(Mandatory=$false)] [String]$pasteFormat ) $uri = 'http://pastebin.com/api_public.php' $request = [System.Net.WebRequest]::Create($uri) $request.ContentType = "application/x-www-form-urlencoded" $request.Method = "POST" [System.Net.ServicePointManager]::Expect100Continue = $false if (!(Test-Proxy)) { if (!$Script:proxyCred) { $Script:proxyCred = Get-Credential } $request.Proxy.Credentials = $Script:proxyCred } #start constructing parameters $parameters = "paste_code=$pasteCode" if ($pasteName -ne "") { $parameters += "&paste_name=$pasteName" } if ($pasteEmail -ne "") { $parameters += "&paste_email=$pasteEmail" } if ($pasteSubDomain -ne "") { $parameters += "&paste_subdomain=$pasteSubDomain" } if ($pastePrivate) { $parameters += …

Viewing all articles
Browse latest Browse all 34

Trending Articles