PowerShell: Run PowerShell script on mutiple remote servers

Home/All Posts, PowerShell, Server/PowerShell: Run PowerShell script on mutiple remote servers

PowerShell: Run PowerShell script on mutiple remote servers

The script below allows you to run PowerShell script on multiple remote servers at once.

INFO: You can customize the script by changing the orange text.
The first orange text line can be changed if your text file of servers is placed somewhere else.
Replace the second orange text line with the PowerShell Script you want to run against your servers.

 

The picture below shows, how you format your text file correctly.

 

Run PowerShell script on multiple remote servers script:

$Servers = get-content c:\temp\servers.txt</span>
foreach($Server in $Servers)
{

invoke-Command -ComputerName $Server -ScriptBlock get-service wuauserv | select-object status</span> }
}

About the Author:

Leave A Comment