Running Programs as Different User

If you ever needed to run a program as someone else, you can use Start-Process and supply alternate credentials. When you do that, you should also make sure you specify -LoadUserProfile to load the user profile unless you do not need it:

Start-Process powershell -LoadUserProfile -Credential (Get-Credential)

With UAC enabled, this will always launch the program without administrator privileges. However, you can elevate another console from here if you like, and it will continue to run as the user you specified to launch the first program.

Twitter This Tip! ReTweet this Tip!


Posted Oct 28 2010, 08:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.