question

HarukiNguyen-0285 avatar image
0 Votes"
HarukiNguyen-0285 asked HarukiNguyen-0285 edited

How to change $PROFILE value in Powershell?

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-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

smfx avatar image
0 Votes"
smfx answered smfx edited

@HarukiNguyen-0285
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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.