Open Powershell command line as Admin from a limited user account
Sometimes at work I have to execute something with admin permissions in user’s machines, but normally the final users are not administrators. For these cases my coworkers tell me to log off and switch to an administrator user, but some computers are slow and this process take me minutes.
I wanted to be efficient so I did a research and I found this simple solution: just execute this command:
runas /noprofile /user:DOMAIN\USERNAME "powershell.exe Start-Process powershell.exe -Verb runAs"
(Remember to change DOMAIN\USERNAME with your credentials, you will be asked for the password after executing this command)
The command explained
runas executes something as other user.
/noprofile prevents loading the user profile in order to execute anyhing faster. Read this if you are not sure that you can use this param: About User Profiles, or simply remove this param.
"powershell.exe Start-Process powershell.exe -Verb runAs" is the command to be executed. In this case executes a powershell command line with admin privileges. Take in care that it is not possible to execute the command
powershell.exe -Verb runAs directly because the powershell window will close immediately.