Connecting to a Remote Server to throw an Invoke Command - server

I am very clueless on what I'm doing but I want to understand on how I can connect to a remote server.
I'm trying to throw this command:
Invoke-Command -Credential $UserCred -ComputerName "IPAddress" -ArgumentList $Command -ScriptBlock {cmd /c $CommandInside}
but it gives me this error:
The client cannot connect to the destination specified in the request.
Verify that the service on the destination is running and is accepting
requests. Consult the logs and documentation for the WS-Management
service running on the destination, most commonly IIS or WinRM.
I tried WinRM it is already running both machines, but none of it seems to work.
Also, I can ping the remote server but the remote server can't ping my machine. Why is that? Does it have something to do with domain?

Related

Can't run command Invoke-Command on server returning status 504, in powershell

I'm trying to run a remote powershell command using this command
Invoke-Command -ComputerName myServer -Credential $Cred -ScriptBlock{hostname}
However, the command returns the following error:
Connecting to remote server myServer failed with the following error message : The WinRM client received an HTTP status code of 504 from the remote WS-Management service. For more information, see the about_Remote_Troubleshooting Help topic.
I've compared the configuration of different machines and the only difference that I've encountered is
In the non-working machine the server proxy is setup automatically, unlike the other machines that is set manually (however the machines do not communicate through a proxy server) List item
When I run the command winrm e winrm/config/listener in cmd, the non-working machines returns an IPv6 IP, unlike the others that only return IpV4 IPs
Can these configurations have something to do with the invoke-command not working?

Impossible to invoke command on a server (Powershell)

I've got a problem, i can't execute a powershell command in remote.
Invoke-Command -ComputerName MYCOMPUTER -Credential MYDOMAIN\MYUSER -ScriptBlock {Get-Culture}
and this is my error log:
Winrs error:WinRM cannot process the request. The following error
occured while using Kerberos authentication: The network path was not
found.
Possible causes are:
-The user name or password specified are invalid.
-Kerberos is used when no authentication method and no user name are
specified.
-Kerberos accepts domain user names, but not local user names.
-The Service Principal Name (SPN) for the remote computer name and
port does not exist.
-The client and remote computers are in different domains and there
is no trust between the two domains.
After checking for the above issues, try the following:
-Check the Event Viewer for events related to authentication.
-Change the authentication method; add the destination computer to
the WinRM TrustedHosts configuration setting or use HTTPS transport.
I've got full rights on the server, i did "Enable-PSRemoting -Force" in admin, ,WinRm quickconfig" too, and i can ping the server and connect at it.
It's strange because i can do it on another server which has the same version of Windows (Windows Server 2008 R2) and the same version of powershell (2.0).
Could you help me please ?
Thanks
You can verify the availability of trusted hosts :
Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator.
At the PowerShell prompt, you can verify that the WinRM service is running using the following command:
get-service winrm
The value of the Status property in the output should be “Running”.
To configure Windows PowerShell for remoting, type the following command:
Enable-PSRemoting –force
Use the below command to add the remote systems under trusted hosts:
winrm s winrm/config/client '#{TrustedHosts="RemoteComputer"}'
Then you can check the same using the below command:
winrm quickconfig
Reference Link : Enabling Remoting in Powershell

How to enable WinRM remotely?

I am running one of my powershell script on remote machine and I got below error.
[server1.cn.oim.com] Connecting to remote server server1.cn.oim.com failed with the following error message : The client cannot connect to the destination specified in the request. Verify that the service on the
destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the
following command on the destination to analyze and configure the WinRM service: "winrm quickconfig".
I am calling all host name in $server and is there any powershell script so that WinRM can be enabled remotely ?

Enter-PSSession to remote server fails with “access is denied”

I want to use winrm remote vm, I can connect to the localhost, but I can't connect to the other remote machine, the error is "access is denied".
Please help me.
You need to provide -Credential parameter:
Enter-PSSession –ComputerName Server –Credential Domain\UserName
So I was having the EXACT same issue as this user and found the issue. Basically I was running the commands as my Domain Admin account but the servers are locked down to not accept network connections from Domain Admin accounts in Group Policy as a security measure. Once changing the command credentials to run as my non domain admin account and an account allowed network access with administrative permissions the enter-pssession command worked perfectly. What I don't understand is why the test-wsman command appears to work.

Powershell remoting issue

I am trying to use powershell remoting from Server A to server B using Enter-PSSession -Computername ServerB. Both servers are in the same domain. Remoting is enabled on server B using Enable-PSRemoting , which has worked fine. I can use Enter-PSSession -computername command from ServerA to other servers fine.
when trying Enter-PSSession -Computername ServerB from SErver A, it gives following error:
FullyqualifiedErrorId: CreateRemoteRunSpaceFailed
Running winrm get winrm/config on serverB gives following:
Listener
Address = *
Transport = HTTP
Port = 5985
Hostname
Enabled = true
URLPrefix = wsman
CertificateThumbprint
ListeningOn = 127.0.0.1, 192.168.0.4, ::1, 2002:b40a:1a8b::b40a:1a8b, fe80::100:7f:fffe%12, fe80::200:5efe:180.10.26.139%14, fe80::681a:e480:25fd:e50e%13
Firewall on all servers is off.
Any Idea on "FullyqualifiedErrorId: CreateRemoteRunSpaceFailed" error?
thanks
vb
Do you have a matching user account on server B? Have you tried doing:
Enter-PSSession -Computername ServerB -Credential (Get-Credential)
and setting your domain username/password?
Have you added the other server(ServerB) to trusted hosts list in serverA? If not add it as below:
Set-Item WSMan:\localhost\Client\TrustedHosts ServerB
Trusted hosts and local accounts should not be used if the machines are in the same domain and the user has local admin rights.
The machines
Can you ping Server b from server a?
You said you can remote to other machines from Server A can you remote to Server B from other machines?
Has your user account got local admin rights on server B?