Brandon Whitehill
Brandon Whitehill

Reputation: 1

Running a script off local machine to remote using Invoke-Command

Here is the command I am trying to run

Invoke-Command -ComputerName DOG-02 C:\Users\user\Documents\PowerShell\PowerShellmenuz.ps1

I want to be able to run the script PowerShellmenuz.ps1 on a remote machine. I am very close but am stuck at this point.

Upvotes: 0

Views: 426

Answers (1)

Yuri
Yuri

Reputation: 1814

It is hard to tell where is the problem without error output, but probably you've missed first configuration step on remote machine. There things that should be done before executing scripts on remote machine.

  • Enabling PowerShell Remoting on the computer that you want access remotely. Open a PowerShell window as Administrator – right click the PowerShell shortcut and select "Run as Administrator". And execute the following command:

Enable-PSRemoting -Force - it will start service WinRM to allow incoming connections.

Upvotes: 1

Related Questions