Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [reflection.assembly]::loadwithpartialname("System.Windows.Forms") | Out-Null
- [reflection.assembly]::loadwithpartialname("System.Drawing") | Out-Null
- If (-Not (Test-Connection ad.dbs.fr -Quiet))
- {
- $output = [System.Windows.Forms.MessageBox]::Show("Please connect to the DBS network first", "Error occured" , '0', 'Error')
- If ($output -eq "OK")
- {
- Exit
- }
- }
- If (-Not (whoami | findstr -i "adm"))
- {
- $output = [System.Windows.Forms.MessageBox]::Show("Please run the program as adm", "Error occured" , '0', 'Error')
- If ($output -eq "OK")
- {
- Exit
- }
- }
- Function Child ($Parentlabel)
- {
- $objComputer = Get-ADComputer $Parentlabel.TEXT
- $BitlockerObject = Get-ADObject -Filter {objectclass -eq 'msFVE-RecoveryInformation'} -SearchBase $objComputer.DistinguishedName -Properties 'msFVE-RecoveryPassword'
- $BitlockerObject = $BitlockerObject | Select-Object -Property ObjectGUID, msFVE-RecoveryPassword | Select-Object @{Label="ID";Expression={$_.ObjectGUID}}, @{Label="Recovery Key";Expression={$_."msFVE-RecoveryPassword"}} | Format-List | Out-String
- $bitlockerGUIbis = New-Object system.Windows.Forms.Form
- $bitlockerGUIbis.Text = "GetBitlockerKeys"
- $bitlockerGUIbis.Name = "GBK"
- $bitlockerGUIbis.DataBindings.DefaultDataSourceUpdateMode = 0
- $bitlockerGUIbis.ClientSize = New-Object System.Drawing.Size(590,224)
- $iconBase64 = 'AAAA'
- $iconBytes = [Convert]::FromBase64String($iconBase64)
- $stream = New-Object IO.MemoryStream($iconBytes, 0, $iconBytes.Length)
- $stream.Write($iconBytes, 0, $iconBytes.Length);
- $iconImage = [System.Drawing.Image]::FromStream($stream, $true)
- $bitlockerGUIbis.Icon = [System.Drawing.Icon]::FromHandle((New-Object System.Drawing.Bitmap -Argument $stream).GetHIcon())
- $bitlockerGUIbis.Add_Closing({[System.Windows.Forms.Application]::Exit($null)})
- $recoveryKeyField = New-Object System.Windows.Forms.RichTextBox
- $recoveryKeyField.ClientSize = New-Object System.Drawing.Size(562,160)
- $recoveryKeyField.Location = New-Object System.Drawing.Point(13,13)
- $recoveryKeyField.Font = [System.Drawing.Font]::new('Calibri', 12)
- $recoveryKeyField.Anchor = 'Top','Right','Bottom','Left'
- $recoveryKeyField.Text = [string]$BitlockerObject
- #$recoveryKeyField.Text = "601381-464343-357159-585849-665588-463507-119416-469931"
- #$recoveryKeyField.AppendText("`nhi")
- $bitlockerGUIbis.Controls.Add($recoveryKeyField)
- $copyToCBButton = New-Object System.Windows.Forms.Button
- $copyToCBButton.ClientSize = New-Object System.Drawing.Size(565,23)
- $copyToCBButton.Location = New-Object System.Drawing.Point(13,190)
- $copyToCBButton.Text = "Copy to Clipboard"
- $copyToCBButton.DataBindings.DefaultDataSourceUpdateMode = 0
- $copyToCBButton.Add_Click({Echo $recoveryKeyField.SelectedText | Clip; [System.Windows.Forms.Application]::Exit($null)})
- $bitlockerGUIbis.Controls.Add($copyToCBButton)
- $bitlockerGUIbis.ShowDialog()
- }
- $InitialFormWindowState = New-Object System.Windows.Forms.FormWindowState
- $bitlockerGUI = New-Object System.Windows.Forms.Form
- $bitlockerGUI.Text = "GetBitlockerKeys"
- $bitlockerGUI.Name = "GBK"
- $bitlockerGUI.DataBindings.DefaultDataSourceUpdateMode = 0
- $bitlockerGUI.ClientSize = New-Object System.Drawing.Size(270,100)
- $iconBase64 = 'AAA=='
- $iconBytes = [Convert]::FromBase64String($iconBase64)
- $stream = New-Object IO.MemoryStream($iconBytes, 0, $iconBytes.Length)
- $stream.Write($iconBytes, 0, $iconBytes.Length);
- $iconImage = [System.Drawing.Image]::FromStream($stream, $true)
- $bitlockerGUI.Icon = [System.Drawing.Icon]::FromHandle((New-Object System.Drawing.Bitmap -Argument $stream).GetHIcon())
- $machineNameLabel = New-Object System.Windows.Forms.Label
- $machineNameLabel.Name = "machineNameLabel"
- $machineNameLabel.Size = New-Object System.Drawing.Size(240,23)
- $machineNameLabel.Text = "Enter the machine name :"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 13
- $System_Drawing_Point.Y = 13
- $machineNameLabel.Location = $System_Drawing_Point
- $machineNameLabel.DataBindings.DefaultDataSourceUpdateMode = 0
- $bitlockerGUI.Controls.Add($machineNameLabel)
- $machineNameEdit = New-Object System.Windows.Forms.TextBox
- $machineNameEdit.Name = "MachineNameEdit"
- $machineNameEdit.Size = New-Object System.Drawing.Size(155,23)
- $machineNameEdit.Text = "DUBB"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 13
- $System_Drawing_Point.Y = 37
- $machineNameEdit.Location = $System_Drawing_Point
- $machineNameEdit.DataBindings.DefaultDataSourceUpdateMode = 0
- $bitlockerGUI.Controls.Add($machineNameEdit)
- $getKeyButton = New-Object System.Windows.Forms.Button
- $getKeyButton.TabIndex = 0
- $getKeyButton.Name = "GetKeysButton"
- $getKeyButton.Size = New-Object System.Drawing.Size(240,23)
- $getKeyButton.UseVisualStyleBackColor = $True
- $getKeyButton.Text = "Get the recovery key(s)"
- $System_Drawing_Point = New-Object System.Drawing.Point
- $System_Drawing_Point.X = 13
- $System_Drawing_Point.Y = 69
- $getKeyButton.Location = $System_Drawing_Point
- $getKeyButton.DataBindings.DefaultDataSourceUpdateMode = 0
- $getKeyButton.add_Click({Child $machineNameEdit})
- $bitlockerGUI.Controls.Add($getKeyButton)
- $InitialFormWindowState = $bitlockerGUI.WindowState
- $bitlockerGUI.add_Load({$bitlockerGUI.WindowState = $InitialFormWindowState})
- $bitlockerGUI.ShowDialog()| Out-Null
Add Comment
Please, Sign In to add comment