Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <# This form was created using POSHGUI.com a free online gui designer for PowerShell
- .NAME
- Ticket Request
- #>
- Add-Type -AssemblyName System.Windows.Forms
- [System.Windows.Forms.Application]::EnableVisualStyles()
- #region begin GUI{
- $Form = New-Object system.Windows.Forms.Form
- $Form.ClientSize = '545,400'
- $Form.text = "Ticket Request Form"
- $Form.TopMost = $false
- $Label1 = New-Object system.Windows.Forms.Label
- $Label1.text = "Email"
- $Label1.AutoSize = $true
- $Label1.width = 25
- $Label1.height = 10
- $Label1.location = New-Object System.Drawing.Point(25,78)
- $Label1.Font = 'Microsoft Sans Serif,10'
- $Label2 = New-Object system.Windows.Forms.Label
- $Label2.text = "Request Type"
- $Label2.AutoSize = $true
- $Label2.width = 25
- $Label2.height = 10
- $Label2.location = New-Object System.Drawing.Point(25,114)
- $Label2.Font = 'Microsoft Sans Serif,10'
- $Label3 = New-Object system.Windows.Forms.Label
- $Label3.text = "Subject"
- $Label3.AutoSize = $true
- $Label3.width = 25
- $Label3.height = 10
- $Label3.location = New-Object System.Drawing.Point(25,152)
- $Label3.Font = 'Microsoft Sans Serif,10'
- $Label4 = New-Object system.Windows.Forms.Label
- $Label4.text = "Description"
- $Label4.AutoSize = $true
- $Label4.width = 25
- $Label4.height = 10
- $Label4.location = New-Object System.Drawing.Point(25,195)
- $Label4.Font = 'Microsoft Sans Serif,10'
- $TextBox1 = New-Object system.Windows.Forms.TextBox
- $TextBox1.multiline = $false
- $TextBox1.width = 100
- $TextBox1.height = 20
- $TextBox1.location = New-Object System.Drawing.Point(-12,-19)
- $TextBox1.Font = 'Microsoft Sans Serif,10'
- $email = New-Object system.Windows.Forms.TextBox
- $email.multiline = $false
- $email.width = 267
- $email.height = 20
- $email.location = New-Object System.Drawing.Point(122,74)
- $email.Font = 'Microsoft Sans Serif,10'
- $subject = New-Object system.Windows.Forms.TextBox
- $subject.multiline = $false
- $subject.width = 267
- $subject.height = 20
- $subject.location = New-Object System.Drawing.Point(122,147)
- $subject.Font = 'Microsoft Sans Serif,10'
- $description = New-Object system.Windows.Forms.TextBox
- $description.multiline = $true
- $description.width = 267
- $description.height = 163
- $description.location = New-Object System.Drawing.Point(122,190)
- $description.Font = 'Microsoft Sans Serif,10'
- $request = New-Object system.Windows.Forms.ComboBox
- $request.width = 267
- $request.height = 20
- @('Maintenance','Technology') | ForEach-Object {[void] $request.Items.Add($_)}
- $request.location = New-Object System.Drawing.Point(122,113)
- $request.Font = 'Microsoft Sans Serif,10'
- $btn1 = New-Object system.Windows.Forms.Button
- $btn1.text = "Send Request"
- $btn1.width = 98
- $btn1.height = 40
- $btn1.location = New-Object System.Drawing.Point(418,323)
- $btn1.Font = 'Microsoft Sans Serif,10'
- $Form.controls.AddRange(@($Label1,$Label2,$Label3,$Label4,$TextBox1,$email,$subject,$description,$request,$btn1))
- #region gui events {
- $btn1.Add_Click({ sendRequest })
- #endregion events }
- #endregion GUI }
- function sendRequest()
- {
- # API Key
- $FDApiKey="apikey"
- #################################################
- # Force TLS1.2 as Powershell defaults to TLS 1.0 and Freshdesk will fail connections
- [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::TLS12
- # Prep
- $pair = "$($FDApiKey):$($FDApiKey)"
- $bytes = [System.Text.Encoding]::ASCII.GetBytes($pair)
- $base64 = [System.Convert]::ToBase64String($bytes)
- $basicAuthValue = "Basic $base64"
- $FDHeaders = @{ Authorization = $basicAuthValue }
- ##################################################
- Invoke-WebRequest "https://clasd.freshdesk.com/api/v2/tickets/" -Headers $FDHeaders -ContentType "application/json" -Method Post -Body " { 'description':'$description.Text','email':'$email.Text', 'subject':'$subject.Text','type':'$request.Text','priority':'1', 'status':'2' }"
- }
Advertisement
Add Comment
Please, Sign In to add comment