Ezine 186 - Grappling with PowerShell's RemotingEzine 186 - Grappling with PowerShell 2.0 RemotingNormally Microsoft products are so easy to install that you don't need any instructions. However, PowerShell v 2.0 with 'Remoting' is an exception; in fact, creating remote sessions is so difficult for beginners that I have devoted a whole article to achieve this single mission. Remoting in Microsoft PowerShell v 2.0
This Week's SecretRemoting is PowerShell v 2.0's jewel in the crown. The ability to run the wonderful PowerShell commands against another machine transforms what you can achieve by typing away at your command-line. Now for the bad news, getting starting with remoting is hard. Most of the articles about PowerShell's remote capabilities are written by experts, people who are not only comfortable with command line syntax, but also, in a previous life, have probably written a shell program from scratch. This Week's MissionMy Mission is solely to get you started with remoting. Firstly, set aside any thoughts of safe procedures; on each test machine logon locally as THE administrator, then disable the firewalls on each test computer. Furthermore, before you launch either PowerShell or the cmd DOS box, right click and select 'Run as administrator', that way if a command does not work it won't be due to lack of security rights. Once you gain success with remoting commands, then naturally revert to normal security and start turning on firewalls, and logging on with normal accounts. The crucial concept for this mission is to get PowerShell remoting working is that we need an additional shell program called WinRm. If you have used a command line program such as NetSh then the concepts involved in configuring WinRm will be vaguely familiar. I got my copy of WinRm from Microsoft Connect, I recommend registering with this site because you never know when you are going to need some its vast library of software. Also be sure to install the same version of WinRm and PowerShell v 2.0 on both test machines. Incidentally, that in itself can be a major challenge if you have to uninstall a previous version, but in the mean time you have applied a service pack. Two Types of PowerShell Remoting
It's time to point out that there are two varieties of Microsoft PowerShell remoting; the
more sophisticated variation employs cmdlets containing the word PSSession,
check what's available with
this cmdlet:
But there is also a more basic form of remoting which merely extends local commands by appending
the -computerName parameter; the result is that your instructions run against
another named machine on the network. For example:
For a list of cmdlets that support this simple remote behaviour try: For the full list you need to add: -and $_.parameters.keys -notContains "Session" Get Started with Basic RemotingI strongly recommend that you gain confidence by starting with the basic form of remoting, my reasoning is that it does not require you configuring the tricky WinRm shell. My thinking is that when you are learning anything new, not just PowerShell, there is nothing like success to encourage exploring the boundaries of what is possible. Thus once you have mastered a PowerShell technique on the local computer it's only natural try to run the same command on a remote machine.
get-services (Local Machine) If you are looking for handy network utilities, try some of the free downloads at Tools4Ever WinRm - The Pre-requisite for PowerShell Remoting
Even with all the components installed correctly, (PowerShell v 2.0 CTP3, .Net Framework and WinRm), remoting still won't work
until you run this cmdlet from within PowerShell (not DOS): Note that unlike PSSession commands, this function only has one 'S' PSRemoting. Actually, the underling cmdlet is Enable-PSSessionConfiguration.
The two commonest traps with WinRm are, trying to configure this command
from inside PowerShell, when you should be at the cmd (DOS box) command line. In particular the 'set' verb works with
cmd but not with PowerShell. The second trap is remembering to right
click and 'Run as administrator'.
The error messages do give tiny clues to the underlying problem, but they
don't give many ideas for a solution. This is why I recommend investigating the WinRm syntax, I would start with
Having noted the verbs, 'get', 'set' and 'enumerate', I would try
Two more useful commands Any problems, remember, you should be in the DOS box and not PowerShell. Also, you did right click and 'Run as administrator', didn't you? Naturally you have to run the same WinRm setup techniques on both the host machine and the test 'victim' machine.
Configuring TrustedHosts drove me mad, I suggest you try this command,
especially noting the famous * wildcard: Guy Recommends:
The Free IP Address Tracker (IPAT)
| |||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Home Copyright © 1999-2012 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |