How do I use Invoke-Command correctly?

rated by 0 users
This post has 3 Replies | 2 Followers

Top 50 Contributor
Posts 69
jwhite Posted: 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: http://technet.microsoft.com/en-us/library/dd347578.aspx, 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.

Top 10 Contributor
Posts 658
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:

http://social.technet.microsoft.com/Forums/zh/winserverpowershell/thread/5078f77d-4bd2-4ad5-ae43-e8350c6da84c

Top 50 Contributor
Posts 69

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 company.com

$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,  server01.company.com and server02.company.com.  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:

$variable3:

server01.company.com

server02.company.com

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

 

Top 75 Contributor
Posts 36

Try $var3 = $var1 + $var2

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