Home > Mobile >  Changing profile path of windows 11 terminal
Changing profile path of windows 11 terminal

Time:07-17

I'm trying to setup shortcuts (command aliases) in Windows 11 terminal.

When I try to run the command:

echo $profile

It gives me the path:

C:\Users\ashut\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

Now if I try to save aliases to this file, it says file is not digitally signed.

I need to set profile path to:

C:\Users\ashut\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1

I tried to create new profile but couldn't found an option to set the path. It allowed only startup path to set.

I my previous computer, profile path was not pointing to OneDrive. How to fix this?

CodePudding user response:

PowerShell's profile paths are not configurable.[1]

Since your OneDrive path should be considered a local path, the implication is that the effective execution policy is AllSigned.

If you don't want to sign your profile file, use a less restrictive execution policy; a good compromise is RemoteSigned (only scripts downloaded from the web then require a signature).

# Open a *new* PowerShell session afterwards.
Set-ExecutionPolicy -Force -Scope CurrentUser RemoteSigned

Note:

  • Scoping the change to the current user obviates the need to run from an elevated (admin) session, but obviously only takes effect for the current user.

  • If execution policies are set via GPOs (Group Policy Objects) in your organization, you will not be able to make this change.


[1] If you want a file at C:\Users\ashut\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 to also exist, you can define it as a symbolic link that points to C:\Users\ashut\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1.

  • Related