How to connect to a remote Windows computer using Enter-PSSession on PowerShell?

-1

I am trying to connect to a remote windows computer using Enter-PSSession using PowerShell. As a Linux user, I am not very familiar with the inner working of Windows.

When just using the command I get the following output (in German...):

PS C:\Users\dietz\Documents\WindowsPowerShell> Enter-PSSession -ComputerName 172.16.4.154
Enter-PSSession : Beim Verbinden mit dem Remoteserver ist folgender Fehler aufgetreten: Die Anforderung kann vom WinRM-
Client nicht verarbeitet werden. Unter folgenden Bedingungen kann eine Standardauthentifizierung mit einer IP-Adresse v
erwendet werden: Der Transport ist HTTPS, oder das Ziel ist in der TrustedHosts-Liste aufgeführt, und es werden explizi
te Anmeldeinformationen bereitgestellt. Verwenden Sie "winrm.cmd", um TrustedHosts zu konfigurieren. Beachten Sie, dass
 Computer in der TrustedHosts-Liste möglicherweise nicht authentifiziert sind. Führen Sie folgenden Befehl aus, um weit
ere Informationen zum Konfigurieren von TrustedHosts anzuzeigen: winrm help config. Weitere Informationen finden Sie im
 Hilfethema "about_Remote_Troubleshooting".
Bei Zeile:1 Zeichen:16
+ Enter-PSSession <<<<  -ComputerName 172.16.4.154
    + CategoryInfo          : InvalidArgument: (172.16.4.154:String) [Enter-PSSession], PSRemotingTransportException
    + FullyQualifiedErrorId : CreateRemoteRunspaceFailed

On the remote computer I tried to use the following command:

C:\Windows\system32>winrm quickconfig
WinRM is not set up to receive requests on this machine.
The following changes must be made:

Set the WinRM service type to delayed auto start.
Start the WinRM service.
Configure LocalAccountTokenFilterPolicy to grant administrative rights remotely
to local users.

Make these changes [y/n]? y

WinRM has been updated to receive requests.

WinRM service type changed successfully.
WinRM service started.
Configured LocalAccountTokenFilterPolicy to grant administrative rights remotely
 to local users.
WSManFault
    Message
        ProviderFault
            WSManFault
                Message = WinRM firewall exception will not work since one of th
e network connection types on this machine is set to Public. Change the network
connection type to either Domain or Private and try again.

Error number:  -2144108183 0x80338169
WinRM firewall exception will not work since one of the network connection types
 on this machine is set to Public. Change the network connection type to either
Domain or Private and try again.

and this command

C:\Windows\system32>winrm quickconfig -transport:https
WinRM already is set up to receive requests on this machine.
WSManFault
    Message
        ProviderFault
            WSManFault
                Message = Cannot create a WinRM listener on HTTPS because this m
achine does not have an appropriate certificate. To be used for SSL, a certifica
te must have a CN matching the hostname, be appropriate for Server Authenticatio
n, and not be expired, revoked, or self-signed.

Error number:  -2144108267 0x80338115
Cannot create a WinRM listener on HTTPS because this machine does not have an ap
propriate certificate. To be used for SSL, a certificate must have a CN matching
 the hostname, be appropriate for Server Authentication, and not be expired, rev
oked, or self-signed.

I do not want to change any connection type (because I have no idea how to do that, and it might complicate other connections), and I would like to avoid anything with certificates. I just want to be able to execute a command on a remote computer to stop and start services. What is the most easy way to accomplish this?

P.S. Security or encryption of the connection is not required.

Alex

Posted 2014-07-15T07:17:55.720

Reputation: 337

Sounds like you need to set the network to Home or Workplace for WinRM to be able to accept connections - as per your second excerpt WinRM firewall exception will not work since one of the network connection types on this machine is set to Public – Lawrence – 2014-07-15T07:29:49.530

And how to do that? – Alex – 2014-07-15T07:31:27.697

Are you using Windows 7 or Windows 8 ? A quick google search may be able to get some guides for you. – Lawrence – 2014-07-15T07:36:15.497

There is a nice screenshot walkthrough under http://www.sevenforums.com/tutorials/43629-network-location-set-home-work-public-network.html, but I cannot proceed to after step2. I am not able to click on the name 'Public Network' (in my case). The computer seems to belong to a 'homegroup' which might complicate things.

– Alex – 2014-07-15T07:46:11.867

Answers

1

I do not want to change any connection type (because I have no idea how to do that, and it might complicate other connections), and I would like to avoid anything with certificates. I just want to be able to execute a command on a remote computer to stop and start services. What is the most easy way to accomplish this?

It's not going to happen. You need to either change the connection type from HTTPS or get the computer a certificate to use with HTTPS (requires certificates).

What you really want is this:

Enable and Use Remote Commands in Windows PowerShell

Colyn1337

Posted 2014-07-15T07:17:55.720

Reputation: 1 191