Is there a trick to pipe get-pssession | invoke-command -session?
If I create the session using variable, $session1, $session2, $session3 I can use invoke-command -session $session1,$session2,$session3 but the previous pipe dont work as I expect.
The goal is to take a list from my internal ticketing server, and run the same command against 50+ server.
All of those server are enabled for remoting using SSL and they are all working individually.
Similarly, when the command runs in a persistent session (PSSession), the
remote variable must be defined in the same PSSession.
USING LOCAL VARIABLES
You can also use local variables in remote commands, but you must indicate that
the variable is defined in the local session.
Beginning in Windows PowerShell 3.0, you can use the Using scope modifier to
identify a local variable in a remote command.
The syntax of Using is as follows:
The syntax is: $Using:
In the following example, the $ps variable is created in the local session, but
is used in the session in which the command runs. The Using scope modifier
identifies $ps as a local variable.
Actually, I am an MSP, I take care of 250 different SMB.
Some of them as only few computer and a DC, some get exchange. Most of them are using Hyper-V host.
Here is another question related to this. Let take a customer with 2 server. Both set-up using SSL. So I had to put a hostname. Ex remote.contoso.com Because I want them both to be available I set-up the first one on port 45986 and second one on port 45987.
If I use invoke-command on those 2 computers at the same time, the result come back and a new column pscomputername is added. In both case, it remote.contoso.com. Internal machine name are different, DC and Hv1. Can we work around this?