Hi guys. I can’t work out how to pass a variable into a new session that also contains a invoke-command.
I have a script and when it runs its triggers as NT Authority\System, so I need to create a new session with creds to connect to another machine and then use invoke-command.
But I can’t work out how to get my variables inside that session.
Also, I am running invoke command against an SCCM server, but the console is available on the local machine but when I remove the - computername argument from the new-pssession, it fails with auth errors… would be good to keep it local if I could.
The first thing I see is that you need to create a param block inside the Invoke-Command if you are using the ArgumentList parameter. The variables inside the param block also have to be listed in the order of the ArgumentList.