Skip to main content

Command Palette

Search for a command to run...

Powershell – Execute a local script on Remote Server

Published
1 min read
Powershell – Execute a local script on Remote Server
P

SQL Server DBA | Powershell |TSQL | Azure

Below is the command to execute the script on remote servers

Reference: https://theitbros.com/run-powershell-script-on-remote-computer/

-- if script is in local drive
Invoke-Command -FilePath c:\ps\tune.ps1 -ComputerName server1,server2,server3

-- if script is in shared network drive
Invoke-Command -FilePath "\\dc03\Share\pstune.ps1" -ComputerName PCS12dd2