Windows PowerShell

Guy recommends:
Free config generator

Solarwinds Config Generator

This CG will put you in charge of controlling changes to network routers and other SNMP devices.

Download your free Config Generator



Windows PowerShell WinRm and WSMan

Windows PowerShell WinRm and WSMan

To get PowerShell's remoting capability working fully, you need an extra 'shell', which is supplied by the WinRm.  Even after the WinRm service install completes successfully, you need to tweak its config settings before the remote sessions become operational.

Remoting in Microsoft PowerShell with WinRm and WSMan

 ♣

Preliminary Discussion of WinRm

WinRm is the underlying engine or resource for PowerShell remoting; it is also the name of the additional executable that you need to download from the Microsoft Connect site.  Once installed, you can access WinRm directly from the 'DOS' command line, or better still, check and amend settings with PowerShell's own WSMan: provider.

WinRm Problem - WSMan Solution

PowerShell has handy commands to create remote sessions such as

# PowerShell v 2.0
Enter-PSSession -computerName otherMachine 

Problem the above command does not work because an WinRm settings called TrustedHosts needs configuring.  To achieve this goal we need to enter what PowerShell calls the WSMan namespace.  (The other alternative is to use cmd and call for WinRm -?)

Use PowerShell Itself to Control TrustedHosts

Preamble:  If you need a refresher on 'cd' (Change directory) try this at the PowerShell command line, for example:
cd c:
or
cd c:\windows

WSMan Example Which Connects to the 'Client' Sub-folder

Rather than a succession of short steps, we could use one longish path statement.  Dir displays the TrustedHosts settings stored in the client sub-folder.

# PowerShell v 2.0
cd wsman::localhost\client
dir

However, if the above does not work then try this alternative line-by-line method:

cd wsman:
cd localhost\client
dir

Please note: cd wsman fails, we need that colon.

cd wsman:  (Succeeds now we can access the wsman 'area', 'namespace' or 'drive'.)

TrustedHosts Goal:  To set, or change TrustedHosts so that any machine can connect remotely.

set-Item TrustedHosts * 
restart-Service WinRm

A more restrictive approach would be to set the value for TrustedHosts to a named machine.

Set-Item TrustedHosts BigServer

Guy Recommends: SolarWinds Engineer's Toolset v10Engineer's Toolset v10

The Engineer's Toolset v10 provides a comprehensive console of utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and the tools teach me more about how the system itself operates.

There are so many good gadgets, it's like having free rein of a sweetshop. Thankfully the utilities are displayed logically: monitoring, discovery, diagnostic, and Cisco tools.  Download your copy of the Engineer's Toolset v 10

Troubleshooting TrustedHosts Remote Connection Problems

  • One common problem is ERROR: Access is denied.
    Solution: Launch PowerShell with elevated rights, in simple language: Run as administrator.
  • Try setting TrustedHosts * on BOTH machines, that is the machine acting as the client as well as the server to which you are trying to establish a session.
  • Remember that for once this is a plural TrustedHostS.
  • Remember to restart the WinRm service, otherwise changes won't take effect, try:
    restart-Service WinRm
  • Keep your eye on the difference between the namespace WSMan and the Windows service winrm.

Summary of Windows PowerShell WinRm and WSMan

To make sure that PowerShell's remoting is not restricted we often need to check the client settings. For this we can use cmd and WinRm, or better, PowerShell and WSMan.  A common use of this technique is to change the TrustedHosts from nobody to everybody. 

See more Microsoft PowerShell tutorials

PShell Home  • Introduction  • Dreams  • 3 Key Commands  • Cmdlet scripts  • Real life tasks

Remote PowerShell  • -Online  • WinRm and WSMan  • Invoke-Command  • Jobs  -asJob

Please write in if you see errors of any kind.  Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.

Download my ebook:Getting Started with PowerShell
Getting Started with PowerShell - only $9.25

You get 36 topics organized into these 3 sections:
   1) Getting Started
   2) Real-life tasks
   3) Examples of Syntax.

In addition to the ebook, you get a PDF version of this  Introduction to PowerShell ebook  It runs to 120 pages of A4.

 *


Google

Web  This website

Review of Orion NPMGuy Recommends: Orion's NPM - Network Performance Monitor

Orion's performance monitor is designed for detecting network outages. A network-centric view make it easy to see what's working, and what needs your attention.

This utility guides you through troubleshooting by indicating whether the root cause is faulty equipment or resource overload.

Download a free trial of the Network Performance Monitor

 

Home Copyright © 1999-2010 Computer Performance LTD All rights reserved

Please report a broken link, or an error.