Powershell Move Profile

This is a workaround I found to change the location of the user specific PowerShell profile file location

Edit, or create, the following file: C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

To create the file in PowerShell

New-Item C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 -ItemType File

To edit

notepad C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1

Then add the following 3 lines

$profile = "P:\profile.ps1"
if ( (test-path $profile) -ne $true) {New-Item $profile -ItemType File}
. $profile

Break down of the code.

This sets the location of the profile

$profile = "P:\profile.ps1"

This checks if the file exists, and creates it if it doesn't

if ( (test-path $profile) -ne $true) {New-Item $profile -ItemType File}

Finally this reloads the shell and forces it to load any settings in the newly defined profile variable

. $profile


You need to set "P:\profile.ps1" to whereever you want the profile saved. This should be a location specific to each user, as if this is the same location for each user the file will be over written every time someone launches powershell. I chose the P: drive since everyone who logs into our server has a unique a unique P: drive for their personal files, so each P: drive is unique to each user.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License