How to change $PROFILE value in Powershell?

Haruki Nguyen 21 Reputation points
2022-05-12T02:14:48.287+00:00

My current $PROFILE value:

C:\Users\usrname\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

And I want to change it into:

C:\Users\usrname\.config\PowerShell\Microsoft.PowerShell_profile.ps1

How can I do that? Thank you ❤.

Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

Accepted answer
  1. K. J. Skinner 181 Reputation points
    2022-05-12T03:54:09.62+00:00

    @Haruki Nguyen
    It builds it off of the Personal value of your user folders, so you could technically change that to C:\Users\usrname.config, but that could have other complications elsewhere. Another option is you could just have C:\Users\usrname\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1 call C:\Users\usrname.config\PowerShell\Microsoft.PowerShell_profile.ps1.

    To change the user folder change this value:
    Item: HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders
    Property: Personal
    Current: C:\Users\usrname\OneDrive\Documents
    New: C:\Users\usrname.config

    To call the other, put this line in C:\Users\usrname\OneDrive\Documents\PowerShell\Microsoft.PowerShell_profile.ps1:

    &"$($UserProfile).config\PowerShell\Microsoft.PowerShell_profile.ps1"  
    

    You might also want to consider $PROFILE.AllUsersCurrentHost as an alternative as well.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.