i had this issue for days now. Done and researched everything pertaining to executing a powershell script on your local machine using winrm.
My goal is to execute these ps1 scripts from my local to a target remote machine. winrm is already configured and working with its basic commands, but i cannot find anything to run a powershell script (*.ps1) using winrm.
something like
winrm {execute ps1 file} -r:http://<IPaddress>:5985 -auth:basic -u:'username' -p:'password' -encoding:utf-8
Any help and suggestions are much appreciated.
Thank you guys!
First of all - I believe you are trying to use
winrs
notwinrm
- latter is used to configure winrm usually, former to run remote commands.With that assumption in mind: I'm pretty sure you will have to pass a script to powershell.exe and take care of escaping command elements. Examples that worked for me (not basic auth, but that irrelevant I think):
Why would anyone want to do it that way is something different I guess. Any good reason why you are requested to go: powershell -> native command -> cmd.exe on remote and -> call PowerShell remotely ?
Doing it like that you loose:
You gain: