Configuring PowerShell For Use With InterMapper

Before you can use PowerShell probes or notifiers, you need to configure the InterMapper machine and any target machines to allow connections. There are many options, and an exhaustive tutorial is beyond the scope of this topic.

Chris Hoffman has written an excellent overview to using PowerShell on remote computers.

Note: This topic assumes you know how to launch PowerShell, and that the InterMapper machine and the machines you want to connect to are running Microsoft Windows.

Enabling PowerShell Remoting

To enable PowerShell remoting, open a PowerShell window, and run the following command (also known as a "cmdlet") on all the machines you want to connect to:

Enable-PSRemoting -Force

The command starts the WinRM service, configures it to start automatically, and creates a firewall rule that permits incoming connections. The -Force attribute accepts the default settings.

Notes:

Configuring TrustedHosts

Note: The configuration of TrustedHosts can result in security vulnerabilities. If you are not well-versed in security issues, you may want to consult an expert.

TrustedHosts is a list of trusted resources for your computer. The TrustedHosts list consists of a comma-separated list of computer names, IP addresses, and fully-qualified domain names. For a given computer, only administrators can change the TrustedHosts list.

Before you can connect to a remote computer, your TrustedHosts list must contain the IP address of that computer.

If your computers are not on a domain, you need to configure the TrustedHosts setting on the InterMapper server for all the computers you want to connect to. Execute these commands, providing an IP address, or use wildcards to specify an IP range (see below). Separate entries with commas.

Setting the Value of TrustedHosts

The following is a sample command that sets values in TrustedHosts.

Set-Item wsman:\localhost\client\trustedhosts [IP address],[IP address], ... Restart-Service WinRM

Using Wildcards When Configuring TrustedHosts

When configuring TrustedHosts, PowerShell accepts only a single asterisk (*) for a wild card.

These are not allowed:

...\trustedhosts *.*.*.*, 192.168.*.*

These are allowed:

...\trustedhosts *, 192.*, 192.168.*

Testing the Connection

To test the configuration, execute this command:

Test-WsMan [COMPUTER]

A successful test shows a several lines of information. The last line is most interesting, as it shows the version of Windows Management (WsMan) running on the target machine.

Executing a Command

You are now ready to try a command. To determine the versions of PowerShell and several other related systems, try this command:

Invoke-Command -ComputerName [Target Computer] -ScriptBlock { $PSVersionTable } -credential [UserName]

This returns a list of versions of PowerShell, WsMan, and several other systems.

If the command above works successfully, you are ready to try running PowerShell probes and notifiers.