Answered by:

How do I use Invoke-Command correctly?

Question

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.

"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.??

invoke-command -session $session -scriptblock {test-outlookconnectivity -protocol:tcp}. That allowed the command to run remotely.

Here is what im wanting to be able to to though. I want to be able to specify a $variable in the -connectionuri, instead of
http://specific server name, I have a list of server names to run a pssession to each, and I want to be able to create one to each server. Is there a way to do something like:

Microsoft is conducting an online survey to understand your opinion of the Technet Web site. If you choose to participate, the online survey will be presented to you when you leave the Technet Web site.