Here’s an example of a PowerShell script that can be used to restart multiple computers:
Define the list of computers to restart (Parameters)
$Computers = @(
“Computer1”,
“Computer2”,
“Computer3”
)
Loop through each computer and restart it
foreach ($Computer in $Computers) {
Write-Host “Restarting computer: $Computer”
Restart-Computer -ComputerName $Computer -Force
}
In this script, you need to define an array of computer names in the $Computers variable. Modify the list to include the names of the computers you want to restart.
The script then uses a foreach loop to iterate over each computer in the list. Inside the loop, the Restart-Computer cmdlet is used to restart each computer. The -Force parameter is used to force the restart without prompting for confirmation.
As the script runs, it will display the name of each computer it is about to restart using the Write-Host cmdlet. You can remove or modify this line if you don’t need the console output.
Please note that to execute this script, you need to have appropriate permissions to restart the remote computers. Additionally, ensure that you have the necessary network connectivity and administrative access to perform the restart remotely.
