0

When using a command like

powershell -command "\\%host1%\supportfiles\mypowershellscript"

from my central server to a remote computer, would it be using that powershell on the remote computer or on my own computer when I run it using the batch?

1 Answer 1

1

When you execute:

PowerShell -command <path to a script>

The script, whether it is located on the local machine or on a remote machine, will execute locally. If you want to execute some PowerShell script remotely, you need to enable remoting on the remote machine using Enable-PSRemoting -force. Then on the local machine, you have to execute your script as administrator and your account also has to have admin privileges on the remote machine. Inside your script you can execute parts of the script remotely like so:

$session = New-PSSession remoteComputerName
Invoke-Command -Session $session -Scriptblock { ... script to execute on remoteComputerName ...}
...
Remove-PSSession $session
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.