I have a user Joey Bloggs, who has recently been migrated to a new domain DOMAINB.TEST. He’s currently logged on to a client in the DOMAINB.TEST domain. However he needs to run a powershell script against servers still residing in DOMAINA.TEST using his old DOMAINA credentials. NB there is a two-way trust between the domains. However he also needs to run the script within an elevated Powershell ISE window.
Windows only provides the option to run as administrator OR a different user. I need to do both.
On the DOMAINB.TEST client Joey Bloggs opens an elevated command prompt and enters:
runas /netonly /user:email@example.com PowerShell_ISE.exe
He’s them prompted to enter his DOMAINA.TEST credentials. The ISE sessions opens elevated and running as firstname.lastname@example.org.
Of course this would work just as well in the same domain. In this scenario Bill is logged in and for some reason needs to run a cmdlet or script as Joey Bloggs and within an elevated session. Bill would complete the following steps:
- Open an elevated command prompt
- Run runas /netonly /user:email@example.com PowerShell_ISE.exe
- Enter Joey’s credentials.
Disclaimer: provided “AS IS” with no warranties and confer no rights