-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShutdown.ps1
27 lines (24 loc) · 867 Bytes
/
Shutdown.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
Function ChoiceMenu {
param(
[string] $caption,
[string] $message,
[string] $yesMessage,
[string] $noMessage,
[int] $defaultChoice
)
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", $yesMessage
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", $noMessage
$options = [System.Management.Automation.Host.ChoiceDescription[]]($yes, $no)
$choiceRTN = $host.ui.PromptForChoice($caption, $message, $options, $defaultChoice)
if ($choiceRTN -eq 0) {
$choiceRTN = $true
}
else {
$choiceRTN = $false
}
Return $choiceRTN
}
$Proceed = ChoiceMenu -caption "Please Confirm Server Shutdown in 10 seconds" -message "Are you Sure You Want To Proceed:" -yesMessage "Server will be shutdown" -noMessage "Nothing will happen" -defaultChoice 1
if ($Proceed) {
&C:\Windows\System32\shutdown.exe /s /t 5
}