Start Windows PowerShell with the "Run as Administrator" option. Only members of the Administrators group on the computer can change the execution policy.
Enable running unsigned scripts by entering:
set-executionpolicy remotesigned
This will allow running unsigned scripts that you write on your local computer and signed
scripts from Internet.
See also Running Scripts at Microsoft TechNet Library.
I think I may have found the issue.
I'd originally been running into problems with the HTTPS listener. I wanted to use an explicit IP but this is only available when using SSL. Setting up the SSL listener with the following:
Set-WSManQuickConfig -UseSSL -Force
or
winrm quickconfig -transport:https -Force
would configure the listener on the server but would still fail when connecting from the client with the -UseSSL
parameter.
I gave up on the IPs and returned to using machine names. I left the attempts to set HTTPS in the script but ran into the issues you were having with the 500 responses when using Credssp
for authentication.
Finally, I decided to try one thing at a time. As soon as I removed the HTTPS settings, things worked!
My full script looks like this:
# Disable/revoke winrm/remoting
Start-Service winrm
winrm invoke restore winrm/config
Disable-PSRemoting -Force
Disable-WSManCredSSP -Role Client
Disable-WSManCredSSP -Role Server
Stop-Service winrm
# Enable remoting
Enable-PSRemoting -Force
Enable-WSManCredSSP -Role Server -Force
Enable-WSManCredSSP -Role Client -DelegateComputer "*.mydomain.com" -Force
winrm enumerate winrm/config/listener
Set-Item WSMan:\localhost\Client\TrustedHosts "*.mydomain.com" -Force
It's certainly not ideal,, but I hope it helps.
Best Answer
basically you have a powershell command and paste it in between these quotes to call it from CMD
powershell -command " #PasteCodeHere "
inside these quotes you have to work with
'
otherwise it will interrupt your command parameter.Edit: Additional Information:
quite often you will encounter this:
powershell -command "& 'somestuff'"
the
&
is used to call a File. when you're only using a command&
is unnessecary, when you want to call a script, you should use it.powershell -command "& 'C:\foobar.ps1'"
You could also use
powershell -file C:\file.ps1
to call a script