Adding variable for invoke-command??

By jcwfbi ·
If I run the cmd:
$session = new-pssession -configurationuri http:..servername.fqdn, then add:
invoke-command -session $session -scriptblock{cmd...}

I found that this will run a command on a remote machine as if i am running it locally.

My problem is I want to specify a variable in the -connectionuri.
I have a list of servers in a variable called $severlist. In this list the servers are labeled as server01,server02, etc. I have another variable that contains the domain name itself that the servers are in called $domain. In it i have the name more than once since there are more than one sever in the domain.

So I'm wanting to do two things, one I want to be able to add the variables $domain, and $serverlist into another variable so that I get something like this: From there add that to the -connectionuri, so that the session can be run on all the servers in the variable. It seems that the http://wants the entire server name, and I don't see a way of getting around that, unless you can use something other than http? End result is to have something like:

new-pssession -configurationname -connectionuri $variable. Is this possible??

Any ideas?? Thx.

This conversation is currently closed to new comments.

0 total posts (Page 1 of 1)  
Thread display: Collapse - | Expand +

All Answers

Share your knowledge
Back to Networks Forum
0 total posts (Page 1 of 1)  

Related Discussions

Related Forums