Here’s the
code:
$server_q= "D-Box-007"
$response_confirmation = [Microsoft.VisualBasic.Interaction]::MsgBox("Restart this server: " + $server_q, 'YesNo', "Confirm
to reboot?")
switch ( $response_confirmation )
{
Yes
{ Restart-Computer -ComputerName $server_q
}
No
{ Write-Host "Restart
Cancelled" }
}
Code above
will prompt the user with “Yes” or “No”, yes will send the restart or reboot
command to the remote server or computer, and no will cancel or exit the execution.
PowerShell code above also demonstrate how to use a switch case statement and use the response to perform an action, in regards to user response or input.
PowerShell code above also demonstrate how to use a switch case statement and use the response to perform an action, in regards to user response or input.
It would prevent
any accidental reboot, and of course the script can be tweak for any operations
that requires user confirmation.
Cheers..till next time. :)
================================
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
Heaven's Dew Fall Prayer app for Android :
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
https://play.google.com/store/apps/details?id=com.myrosaryapp
http://quickbytesstuff.blogspot.sg/2014/09/how-to-recite-rosary.html
Comments
Post a Comment