9

I am unable to execute powershell scripts on a remote server, but only on my current machine - please help.

Running the following script to give a list of a temp directory on the remote server works from other machines to the same server with my credentials, however doesn't work for any users on my machine.

Invoke-Command -ComputerName <server_name> -Credential (Get-Credential) -ScriptBlock { Get-ChildItem "D:\temp" } 

I receive the following error:

[server_name] Connecting to remote server server_name failed with the following error message : Logon failure: unknown user name or bad password. For more information, see the about_Remote_Troubleshooting Help topic. + CategoryInfo : OpenError: (server_name:String) [], PSRemotingTransportException + FullyQualifiedErrorId : LogonFailure,PSSessionStateBroken

  • Yes, there is a d: drive.
  • Yes, there is a temp directory
  • Yes, my credentials are good - I can remote desktop to the server and can execute the script successfully on other machines.

I am running the powershell 3 - downloaded from http://www.microsoft.com/en-us/download/details.aspx?id=34595 and it's installed successfully.

A call to $PsVersionTable on my laptop gives me this:

Name Value
---- -----

WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.586
PSRemotingProtocolVersion 2.2

I'm running Windows 7 and the server is running Windows 2003. I know powershell 3 doesn't play well with Windows 2003 server, but the command above does execute successfully on other client machines so don't believe this to be an issue.

Any ideas?

7
  • Can you use Enter-PSSession on that machine?
    – rtf
    May 30, 2013 at 15:49
  • Running Enter-PSSession pointing to the server I get "WinRM cannot process the request.the following error occured while using Kerberos authentication: Cannot find the computer <server_name> ... " but it is available. May 30, 2013 at 15:56
  • Remote in and run Enable-PSRemoting -force again; seems like a problem with WinRM to me.
    – rtf
    May 30, 2013 at 15:58
  • I've tried that (and just again) but no luck. I can run the command on another machine into the same server though so I'm still thinking it's on the client side ... some how :-( May 30, 2013 at 16:01
  • @WestDiscGolf - I would reimage the client if thats possible. Sounds like a client configuration without more knowlege it will be hard for us to solve.
    – Ramhound
    May 30, 2013 at 16:03

2 Answers 2

6

So after some further diagnosis tests (logging onto another machine to run it, booting into another OS installation on the same laptop) it came down to the needing to run the following command:

Set-Item WSMan:\localhost\Client\TrustedHosts -value * 

Also while doing further investigation I found this site which could help others with remote powershell issues (posting for reference).

0

I'm assuming your using PowerShell v2.0 in your Windows Server 2003 and that you enabled WINRM 2.0 on the server too. PowerShell v3.0 WINRM should connect to Window Server 2003 in that case.

Make sure you run the Enable-PSRemoting on the server as describe by the "WestDiscGolf" notes. Also, you need to check your firewall rules in your Windows 7 client just to make sure.

Give it another try. :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .