Forum Discussion
Run PowerShell with different credentials without prompt on remote machines
You can leverage Start-Process as mentioned above by pvanoord above.
One down side to this method is that you have to pass the credentials across in some fashion, and I've seen a lot of people take the lazy approach of passing them in clear text.
A "better" (subjective statement) approach would be to establish the credential client-side (since most people are familiar with Get-Credential already) and use that in a call to Invoke-Command. Here's a crude example:
$RemoteCredential = Get-Credential;
Invoke-Command -UseSSL -ComputerName somehost.mydomain.com -Credential $RemoteCredential -ScriptBlock { dir C:\ };
(note: if you haven't configured secure WinRM, then leave out the -UseSSL)
Of course, there's other options for achieving the same thing but for this specific use case, this is the one I'd recommend for a few reasons.
If the first one is that it keeps the credential relatively secure, then the second reason would be that Invoke-Command can accept multiple remote hosts for the -ComputerName parameter, and if multiple hosts are provided, it spawns tasks in parallel (up to a default or nominated limit which is beyond the scope of this discussion.)
Where you have to run that command on a large number of remote hosts, this results in significant time savings.
Cheers,
Lain