Because WinGet is not PowerShell-specific, it cannot rely on PowerShell stuff. Instead, it does add to %PATH% (once). It also shows a message when it does this. If you did not see the message, it may have already modified %PATH% in the past. WinGet adds %LOCALAPPDATA%\Microsoft\WinGet\Links\ (in its expanded form) to your user’s %PATH% (not the system-wide one).

WinGet creates symlinks in this folder. These are then usable from any shell or Run prompt.

In my opinion, yes, this method is superior, because it is effective everywhere.

However, it only works with .exe files. If you need PowerShell-specific aliases (involving cmdlets or whatever), you must use PowerShell methods to create them permanently. $profile is the way to go.

Answer from user219095 on Stack Exchange
Top answer
1 of 3
3

Because WinGet is not PowerShell-specific, it cannot rely on PowerShell stuff. Instead, it does add to %PATH% (once). It also shows a message when it does this. If you did not see the message, it may have already modified %PATH% in the past. WinGet adds %LOCALAPPDATA%\Microsoft\WinGet\Links\ (in its expanded form) to your user’s %PATH% (not the system-wide one).

WinGet creates symlinks in this folder. These are then usable from any shell or Run prompt.

In my opinion, yes, this method is superior, because it is effective everywhere.

However, it only works with .exe files. If you need PowerShell-specific aliases (involving cmdlets or whatever), you must use PowerShell methods to create them permanently. $profile is the way to go.

2 of 3
2

From the post How to create permanent PowerShell Aliases, I quote the excellent answer by Naigel :

It's possible to store in a profile.ps1 file any PowerShell code to be executed each time PowerShell starts. There are at least 6 different paths where to store the code depending on which user has to execute it. We will consider only 2 of them: the "all users" and the "only your user" paths (follow the previous link for further options).

To answer your question, you only have to create a profile.ps1 file containing the code you want to be executed, that is:

New-Alias Goto Set-Location

and save it in the proper path:

  • "$Home\Documents" (usually C:\Users\<yourname>\Documents): only your user will execute the code. This is the recommended location You can quickly find your profile location by running echo $profile in PowerShell
  • $PsHome (C:\Windows\System32\WindowsPowerShell\v1.0): every user will execute this code

IMPORTANT: remember you need to restart your PowerShell instances to apply the changes.

TIPS

  • If both paths contain a profile.ps1 file, the all-users one is executed first, then the user-specific one. This means the user-specific commands will overwrite variables in case of duplicates or conflicts.

  • Always put the code in the user-specific profile if there is no need to extend its execution to every user. This is safer because you don't pollute other users' space (usually, you don't want to do that).

  • Another advantage is that you don't need administrator rights to add the file to your user-space (you do for anything in C:\Windows\System32).

  • If you really need to execute the profile code for every user, mind that the $PsHome path is different for 32bit and 64bit instances of PowerShell. You should consider both environments if you want to always execute the profile code.

    The paths are:

  • C:\Windows\System32\WindowsPowerShell\v1.0 for the 64bit environment

  • C:\Windows\SysWow64\WindowsPowerShell\v1.0 for the 32bit one (Yeah I know, the folder naming is counter-intuitive, but it's correct).

Top answer
1 of 14
295

UPDATED - January 2021

It's possible to store in a profile.ps1 file any PowerShell code to be executed each time PowerShell starts. There are at least 6 different paths where to store the code depending on which user has to execute it. We will consider only 2 of them: the "all users" and the "only your user" paths (follow the previous link for further options).

To answer your question, you only have to create a profile.ps1 file containing the code you want to be executed, that is:

New-Alias Goto Set-Location

and save it in the proper path:

  • "$Home\Documents" (usually C:\Users\<yourname>\Documents): only your user will execute the code. This is the recommended location You can quickly find your profile location by running echo $profile in PowerShell
  • $PsHome (C:\Windows\System32\WindowsPowerShell\v1.0): every user will execute this code

IMPORTANT: remember you need to restart your PowerShell instances to apply the changes.

TIPS

  • If both paths contain a profile.ps1 file, the all-users one is executed first, then the user-specific one. This means the user-specific commands will overwrite variables in case of duplicates or conflicts.

  • Always put the code in the user-specific profile if there is no need to extend its execution to every user. This is safer because you don't pollute other users' space (usually, you don't want to do that).
    Another advantage is that you don't need administrator rights to add the file to your user-space (you do for anything in C:\Windows\System32).

  • If you really need to execute the profile code for every user, mind that the $PsHome path is different for 32bit and 64bit instances of PowerShell. You should consider both environments if you want to always execute the profile code.

    The paths are:

    • C:\Windows\System32\WindowsPowerShell\v1.0 for the 64bit environment
    • C:\Windows\SysWow64\WindowsPowerShell\v1.0 for the 32bit one (Yeah I know, the folder naming is counterintuitive, but it's correct).
2 of 14
213

It's not a good idea to add this kind of thing directly to your $env:WINDIR PowerShell folders, unless you truly want your alias to be global.
The recommended way is to add it to your personal profile:

cd $env:USERPROFILE\Documents
md WindowsPowerShell -ErrorAction SilentlyContinue
cd WindowsPowerShell
New-Item Microsoft.PowerShell_profile.ps1 -ItemType "file" -ErrorAction SilentlyContinue
powershell_ise.exe .\Microsoft.PowerShell_profile.ps1

Now add your alias to the Microsoft.PowerShell_profile.ps1 file that is now opened:

function Do-ActualThing {
    # Do the actual thing
}

Set-Alias MyAlias Do-ActualThing

Then save it, and refresh the current session with:

. $profile

Note: Just in case, if you get permission issue like

CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess

Try the below command and refresh the session again.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
🌐
DEV Community
dev.to › adityashrivastavv › how-to-set-permanent-and-temporary-aliases-in-powershell-and-bash-a-step-by-step-guide-1mn9
How to Set Permanent and Temporary Aliases in PowerShell and Bash: A Step-by-Step Guide - DEV Community
June 19, 2024 - ... In this example, ll is an alias for the Get-ChildItem cmdlet, which is similar to ls in Unix-based systems. ... To make an alias permanent, you need to add it to your PowerShell profile script.
🌐
Reddit
reddit.com › r/powershell › how to set alias permanently on windows 11 (coming from linux)
r/PowerShell on Reddit: how to set alias permanently on Windows 11 (coming from Linux)
January 1, 2025 -

I hope this is the right place to ask. Anyone know how can I set these 2 command in alias on Windows 11. In Linux it would be something like

alias sqlstart="net start postgresql-x64-16"
alias sqlstop="net stop postgresql-x64-16"

in ~/.bashrc

🌐
Medium
medium.com › @hello.ash99 › setting-up-aliases-in-powershell-1ad90ec50046
Setting up Aliases in PowerShell. Aliases are shortcuts or alternate… | by Aishwarya Mathew | Medium
June 20, 2024 - Aliases created in a session are temporary. To make them permanent, they can be added to the PowerShell profile script.
🌐
GitHub
gist.github.com › mrgarymartin › d2c296bb6ac019d59009c38f745eec9e
Create a permanent Powershell Alias Profile · GitHub
Using a function the contents of Microsoft.PowerShell_profile.ps1 can be: function Do-ActualThing { # do actual thing } Set-Alias MyAlias Do-ActualThing
Find elsewhere
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › set-alias
Set-Alias (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
You can use Set-Alias to reassign ... such as the description. An alias that's created or changed by Set-Alias isn't permanent and is only available during the current PowerShell session. When the PowerShell session is closed, ...
🌐
SharePoint Diary
sharepointdiary.com › sharepoint diary › powershell › powershell tutorials › powershell aliases: a beginner’s guide
PowerShell Aliases: A Beginner's Guide - SharePoint Diary
October 3, 2025 - By default, any alias you create ... you open PowerShell. If you want to make the Alias permanent, you need to Add Alias to the PowerShell profile....
🌐
Seb Nilsson
sebnilsson.com › blog › powershell-profile-with-permanent-aliases
PowerShell Profile with Permanent Aliases - Seb Nilsson
September 17, 2014 - For example you can create a PowerShell-alias for the git-command to work with just using g instead:
🌐
ScriptRunner
scriptrunner.com › blog-admin-architect › powershell-aliasing
PowerShell Aliasing | ScriptRunner Blog
March 20, 2025 - Everything we did up to now will vanish once you close your current PowerShell session, as setting aliases is not a permanent operation.
🌐
Powershelltutorial
powershelltutorial.net › PS-Script › creating-persistent-aliases-in-powershell.aspx
Powershell Tutorial - Creating Persistent Aliases in PowerShell
There are two commands that PSH has that will assist in making the aliases persistent. They are called Export-Alias (exports the alias information to a file) and Import-Alias.
🌐
Microsoft Learn
learn.microsoft.com › en-us › answers › questions › 1341952 › alias-for-powershell
Alias for PowerShell - Microsoft Q&A
Hello I want to create permanent alias in PowerShell. In my case I want to be able to call Cygwin executables from PowerShell. My Cygwin binaries are located here C:\Cygwin64\bin I could do it for e.g. grep like Set-Alias grep …
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › new-alias
New-Alias (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
Aliases created by using New-Alias are not saved after you exit the session or close PowerShell. You can use the Export-Alias cmdlet to save your alias information to a file. You can later use Import-Alias to retrieve ...
🌐
PDQ
pdq.com › powershell › set-alias
Set-Alias - PowerShell Command | PDQ
You can also use Set-Alias to reassign a current alias to a new command, or to change any of the properties of an alias, such as its description. Unless you add the alias to the Windows PowerShell profile, the changes to an alias are lost when you exit the session or close Windows PowerShell.
🌐
TutorialsPoint
tutorialspoint.com › how-to-create-powershell-alias-permanently
How to create PowerShell alias permanently?
February 14, 2020 - PowerShell alias can be created permanently by 2 methods below. a) Import / Export Alias To export all the aliases, you need to use Export-Alias cmdlet. When you use this command it will ask you the path for
🌐
Medium
frankie95.medium.com › set-alias-command-in-powershell-to-make-your-life-easier-61de600c18d2
Set alias command in powershell to make your life easier | by Frankie | Medium
December 2, 2020 - notepad) to open Microsoft.PowerShell_profile.ps1 · Create new alias command by inputting Set-Alias <name> <value>.
🌐
Xah Lee
xahlee.info › powershell › powershell_aliases.html
PowerShell: List of Aliases
October 21, 2024 - Alias is an alternate name for a command, typically shorter, easier to type. Many commands in PowerShell by default have many aliases, so if you are familiar with cmd.exe or bash, you can use it right away.
🌐
Microsoft Certified Professional Magazine
mcpmag.com › articles › 2014 › 06 › 10 › exe-alias-in-powershell.aspx
Creating EXE Aliases in PowerShell -- Microsoft Certified Professional Magazine Online
June 10, 2014 - If the alias already exists it will be modified. Otherwise a new one will be created. There's no limit to what you can define. I have a PowerShell window open all the time and I find it much easier to start apps like Word or Excel directly from the prompt, instead of hunting for a menu shortcut or desktop icon.