Author Posts

April 5, 2016 at 6:15 pm

I was running the example on pg 252:

Invoke-Command -command {Get-CimInstance -class win32_process } -Session (Get-PSSession -ComputerName loc*)

and get error:
Get-PSSession : Invalid URI: The hostname could not be parsed.

Digging deeper I ran: Get-PSSession -ComputerName *

and get: Get-PSSession : Missing an argument for parameter 'ComputerName'. Specify a parameter of type 'System.String[]' and try again.

then tried: Get-PSSession -ComputerName localhost and THAT worked.

So, tried the wildcard again: Get-PSSession -ComputerName loc*
and get same error: "...Invalid URI: The hostname could not be parsed."

What's up with -ComputerName wild cards as used in the book?

April 5, 2016 at 6:24 pm

The -ComputerName parameter doesn't accept wildcards. Not sure if that's a change from a previous version. Personally, I don't use Get-PSSession at all. When I use New-PSSession, I assign the results to a variable, and a use that variable later on:

$session = New-PSSession -ComputerName localhost

Invoke-Command -Session $session { Do-Stuff }