1

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?

Ashutosh
  • 4,371
  • 10
  • 59
  • 105
  • it relates to execution policy. Check [Get-ExecutionPolicy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/get-executionpolicy?view=powershell-7.2) and [Set-ExecutionPolicy](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2) – phuclv Jul 16 '22 at 14:40

1 Answers1

1

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.

mklement0
  • 382,024
  • 64
  • 607
  • 775