Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Function Convert-GUIDtoBase64{ param ($guid); [system.convert]::ToBase64String(([GUID]$guid).ToByteArray())}
- Function newForm([string] $title, [string] $message, [string] $defaultText)
- {
- Add-Type -AssemblyName System.Windows.Forms
- Add-Type -AssemblyName System.Drawing
- $reply = New-Object System.Windows.Forms.Form
- $reply.Text = $title
- $reply.Size = New-Object System.Drawing.Size(300,200)
- $reply.StartPosition = 'CenterScreen'
- $okButton = New-Object System.Windows.Forms.Button
- $okButton.Location = New-Object System.Drawing.Point(75,120)
- $okButton.Size = New-Object System.Drawing.Size(75,23)
- $okButton.Text = 'OK'
- $okButton.DialogResult = [System.Windows.Forms.DialogResult]::OK
- $reply.AcceptButton = $okButton
- $reply.Controls.Add($okButton)
- $cancelButton = New-Object System.Windows.Forms.Button
- $cancelButton.Location = New-Object System.Drawing.Point(150,120)
- $cancelButton.Size = New-Object System.Drawing.Size(75,23)
- $cancelButton.Text = 'Cancel'
- $cancelButton.DialogResult = [System.Windows.Forms.DialogResult]::Cancel
- $reply.CancelButton = $cancelButton
- $reply.Controls.Add($cancelButton)
- $label = New-Object System.Windows.Forms.Label
- $label.Location = New-Object System.Drawing.Point(10,20)
- $label.Size = New-Object System.Drawing.Size(280,20)
- $label.Text = $message
- $reply.Controls.Add($label)
- $textBox = New-Object System.Windows.Forms.TextBox
- $textBox.Location = New-Object System.Drawing.Point(10,40)
- $textBox.Size = New-Object System.Drawing.Size(260,20)
- $textBox.Text = $defaultText
- $reply.Controls.Add($textBox)
- $reply.Topmost = $true
- $reply.Add_Shown({$textBox.Select()})
- $result = @{ Status=$reply.ShowDialog();Data=$textbox.text}
- $result
- }
- $result = newForm "SSO lookup" "username here" "first.last"
- if ($result['Status'] -eq [System.Windows.Forms.DialogResult]::OK)
- {
- $x = $result['Data']
- Convert-GUIDtoBase64 (get-aduser $x).objectguid| tee -variable identifier | clip
- newForm "SSO Identifier result" "The identifier has been copied to the clipboard" $identifier
- }
Add Comment
Please, Sign In to add comment