Added a lot of stuff
This commit is contained in:
24
functions/Invoke-RebootPrompt.ps1
Normal file
24
functions/Invoke-RebootPrompt.ps1
Normal file
@@ -0,0 +1,24 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Used in Start-ChocoRemotemgmt to prompt if a user wants to reboot a computer.
|
||||
#>
|
||||
Function Invoke-RebootPrompt {
|
||||
param(
|
||||
$Message = "Click OK to reboot",
|
||||
$Title = "Continue or Cancel"
|
||||
)
|
||||
Add-Type -AssemblyName System.Windows.Forms | Out-Null
|
||||
$MsgBox = [System.Windows.Forms.MessageBox]
|
||||
$Decision = $MsgBox::Show($Message,$Title,"OkCancel", "Information")
|
||||
If ($Decision -ne "Cancel") {
|
||||
$outputBox.Text = ""
|
||||
try {
|
||||
$outputBox.Text = ("Rebooting " + $ComputerList.Text)
|
||||
Restart-Computer -ComputerName $ComputerList.Text -Force -ErrorAction stop
|
||||
}
|
||||
catch {
|
||||
$ErrorMessage = $_.Exception.Message
|
||||
$outputBox.Text = $ErrorMessage
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user