InfotechGuyz.com Blog

Accessing Server 2008 remotely using Windows Remote Shell

Run following command to Enable WinRM on remote computer,
WinRM quickconfig

You can use WinRS to connect to a remote server using following command,
Winrs –r:remoteservername cmd

*make sure firewall is not blocking remote connections

Below is the help file from Microsoft

Windows Remote Management Command Line Tool

Configuration for WinRM is managed using the winrm command line or through GPO.
Configuration includes global configuration for both the client and service.

The WinRM service requires at least one listener to indicate the IP address(es)
on which to accept WS-Management requests. For example, if the machine has
multiple network cards, WinRM can be configured to only accept requests from
one of the network cards.

Global configuration
winrm get winrm/config
winrm get winrm/config/client
winrm get winrm/config/service
winrm enumerate winrm/config/service/certmapping
winrm enumerate winrm/config/winrs/customremoteshell

Network listening requires one or more listeners.
Listeners are identified by two selectors: Address and Transport.

Address must be one of:
* - Listen on all IPs on the machine
IP:1.2.3.4 - Listen only on the specified IP address
MAC:... - Listen only on IP address for the specified MAC

Note: All listening is subject to the IPv4Fitler and IPv6Filter under
config/service.
Note: IP may be an IPv4 or IPv6 address.

The configuration that allows a client to run a remote shell and
arguments based on a URI is stored in the CustomRemoteShell table.
The table is identified by the following resource URI:

winrm/config/winrs/customremoteshell

Each entry in this table contains three properties:
URI - The URI of the shell resource.
Shell - The executable to be launched.
Arguments - The arguments to be passed to the shell Shell.

The URI is the key and is case-insensitive; wildcards, internal whitespaces
and '?' character are not allowed.

The shell executable must be specified as a full path.
It can contain environment variables; the environment
variables are expanded on the remote machine.

Example: To see the current CustomRemoteShell configuration
winrm enumerate winrm/config/winrs/customremoteshell

Example: To create an entry for PowerShell:
winrm create winrm/config/winrs/customremoteshell?uri=shell/Microsoft.Powershell @{ Shell="%windir%\system32\windowspowershell\v1.0\PowerShell.exe";Arguments="-s -nologo"}

Transport must be one of:
HTTP - Listen for requests on HTTP (port 80)
HTTPS - Listen for requests on HTTPS (port 443)

Note: HTTP traffic by default only allows messages encrypted with
the Negotiate or Kerberos SSP.

When configuring HTTPS, the following properties are used:
Hostname - Name of this machine; must match CN in certificate.
CertificateThumbprint - hexadecimal thumbprint of certificate appropriate for
Server Authentication.
Note: If only Hostname is supplied, WinRM will try to find an appropriate
certificate.

Example: To listen for requests on HTTP on all IPs on the machine:
winrm create winrm/config/listener?Address=*+Transport=HTTP

Example: To disable a given listener
winrm set winrm/config/listener?Address=IP:1.2.3.4+Transport=HTTP @{Enabled="false"}

Example: To enable basic authentication on the client but not the service:
winrm set winrm/config/client/auth @{Basic="true"}

Example: To enable Negotiate for all workgroup machines.
winrm set winrm/config/client @{TrustedHosts="<local>"}

See also:
winrm help uris
winrm help aliases
winrm help certmapping
winrm help input
winrm help switches


Written by: InfoTechGuyz