Invoke-Command wrapper function
A quick post this time about something that might be helpful for others, something that saves me from typing too much 🙂
I’ve noticed over the last week that I’ve been doing various remoting commands through Invoke-Command to the same machines, which require additional credentials to access.
Why re-type something when you can automate it 🙂
Before
I used to have to do the following:
$SCCMServers = 'CM01.contoso.com','CM02.contoso.com','CM03.contoso.com','CM04.contoso.com'
$cred_SCCM = Import-CliXml $CredStore\contoso.xml
Invoke-Command -ComputerName $SCCMServers -Credential $cred_SCCM -Scriptblock {whatever needed to be done}Where my SCCM servers are in another forest as my management machine and $CredStore is my personal Credential folder which contains credentials for various systems/domains, as I use these regularly and I’m lazy
