How do I use Invoke-Command correctly?

rated by 0 users
Not Answered This post has 0 verified answers | 3 Replies | 2 Followers

Top 50 Contributor
78 Posts
jwhite posted on 03-07-2012 6:14 PM

Im trying to run the command test-outlookconnectivity -protocol:tcp or http -trustanysslcert:$true.  I'm wanting to run it on a remote machine as if I were on the machine, and have the output returned to the screen of the local machine.

As stated in this article:, i tried to use the invoke-command.  My syntax looks like this:

Invoke-command -comuptername <sever name> -scriptblock {test-outlookconnectivity ....} -authentication Kerberos.  However I got this error:

"Connecting to remote server failed with the following error message : WinRM cannot process the request. The following error occured while using Kerberos authentication: The network path was not found."

Anyone got any idea what im doing wrong?  I have permissions to run the cmd on both machines and I can also successfully ping the remote machine.??  Thanks.

All Replies

Top 10 Contributor
658 Posts
Idera Employee

Are you crossing domain trusts? If so, you may want to consider doing some basic network troubleshooting and WinRM troubleshooting. Review in PowerShell with Get-Help about_remote_troubleshooting topic. There is an Administrators Guide to Remoting in the Library on this site.

You may also want to read this post here:

Top 50 Contributor
78 Posts

Ok I got the command to work, turns outs that when you use -connectionuri you have to specify http://fqdn of the server/powershell when running a remote powershell command.  However I have a new challenge.

I have two variables:  $domainid and $server.  $domainid has the fqdn suffix of the server, like

$server has the server name like server01. 

Is there a way to append the two variables together so that each server in the list has the fqdn appened to it.  Like for example, and  Basically I want to create a third variable that appends the fqdn to each server so that when you type in third variable you get:


What I want to do is call the third variable with -connectionuri http://..  Any thoughts??


Top 75 Contributor
50 Posts

Try $var3 = $var1 + $var2

Page 1 of 1 (4 items) | RSS
Copyright 2012 All rights reserved.