I wanted to set up a file that would ask for which branch's server is going down and then email them accordingly to alert them of the restart. I have 2 variables, $server and $setTime. How do I get the the powershell script to read translate those variables into text?
Powershell script:
$MyEmail = "[email protected]"
$SMTP= "mail.email.net"
$To = "[email protected]"
$Subject = "$server Server Restart"
$Body = "All,
We will be restarting the $server server at $setTime.
Printing and folder access wil be offline during the restart.
The server will be offline for 5 minutes.
Helpdesk"
Start-Sleep 2
Send-MailMessage -To $to -From $MyEmail -Subject $Subject -Body $Body -SmtpServer $SMTP -DeliveryNotificationOption never
Batch File:
@echo off
set /p server = What server is being restarted?
set /p setTime = What time?
PowerShell.exe -Command c:\users\%username%\Desktop\dotComEmails\xServerIsDown.ps1 -server