So I have a need to login to other PCs through Windows PowerShell from time to time. Just like I need to SSH to other Linux machines. Well that’s fine, I just open up PS and run
The problem is that I’m usually logged into my PC with an account that does not have permissions to the other PC. If I run PS as a privileged user though, this isn’t a problem. (Yes, I’m sure there’s a way to pass credentials through the Enter-PSSession cmdlet, but that’s not how I solved this.)
One option was to use runas and start PS from the command line
C:WindowsSystem32runas.exe /user:domainusername C:WindowsSystem32WindowsPowerShellv1.0powershell.exe
but then you don’t get the pretty blue PS window and you’re stuck in the command line.
What I ended up having to do was write a PS script to start a PS session under a certain user:
Start-Process powershell.exe -Credential "" -WorkingDirectory "C:"
I called this ps_admin.ps1 and stuck it on my desktop. So now whenever I want to run a PS session as any user, I just click it and get the following popup
From there, I login with any user I want and get the pretty blue PS screen 🙂