45 lines
2 KiB
PowerShell
45 lines
2 KiB
PowerShell
Function Get-PCReboot($ComputerName){
|
|
|
|
$title = "You are about to reboot $ComputerName, are you sure?"
|
|
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes"
|
|
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No"
|
|
|
|
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
|
|
$result = $host.ui.PromptForChoice($title, $decision, $options, 0)
|
|
|
|
switch($result)
|
|
{
|
|
0{
|
|
Write-host "Attempting to Reboot $ComputerName." -ForegroundColor Yellow
|
|
|
|
Write-Host "Executing Bypass..."
|
|
Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {
|
|
|
|
If (Test-Path 'C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe')
|
|
{
|
|
& "C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe" --remove-bypass --admin-passphrase handshake1 --aa
|
|
& "C:\Program Files (x86)\PGP Corporation\PGP Desktop\PGPwde.exe" --add-bypass --disk 0 --count 1 --admin-passphrase handshake1 --aa
|
|
}
|
|
If (Test-Path 'C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe')
|
|
{
|
|
& "C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe" --remove-bypass --admin-passphrase handshake1 --aa
|
|
& "C:\Program Files\PGP Corporation\PGP Desktop\PGPwde.exe" --add-bypass --disk 0 --count 1 --admin-passphrase handshake1 --aa
|
|
}
|
|
}
|
|
|
|
Write-Host "Executing Restart..."
|
|
Invoke-Command -ComputerName $ComputerName -SessionOption (New-PSSessionOption -NoMachineProfile) -ScriptBlock {shutdown -r -t 0}
|
|
Write-Host "Reboot Command as been sent"
|
|
|
|
|
|
}
|
|
|
|
1{
|
|
Write-host "You selected 'No' so this script will now exit." -BackgroundColor Red -ForegroundColor Yellow
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |