August 29, 2022

Run PowerShell script to multiple servers remotely

List all servers (better FQDN or IP) in a txt file name "servers.txt".
Keep the PowerShell script (say script.ps1) at the same location as the text file.

$server=Get-Content C:\servers.txt
Invoke-Command -ComputerName $server -FilePath C:\script.ps1

No comments:

Post a Comment