Windows – How to make PowerShell run as administrator start in the home directory

administratorpowershellwindows 7

Whenever I run PowerShell as administrator, it starts in C:\WINDOWS\system32\WindowsPowerShell\v1.0. How do I make it start in my user's home directory instead? My $HOME has the expected value, i.e., C:\Users\<account>. Whenever I run PowerShell without administrative privileges it starts up in $HOME.

Best Answer

If you always use a shortcut you can just add the arguments:

-NoExit -Command "cd ~"

If you want this to always execute you can make a profile, to do this create the file (and missing folders on the path):

%userprofile%\Documents\WindowsPowerShell\profile.ps1

And place the cd command (cd ~) inside it.

To allow the scripts execution on startup you need to change the execution policy to be less restrictive or bypass it.

To bypass you can pass an argument when starting powershell:

-ExecutionPolicy Bypass

To change the policy run powershell as admin and execute:

Set-Executionpolicy RemoteSigned

Do this at your own risk of course. If you did you will always end up in your home folder on startup.