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).
Answer from Naigel on Stack Overflow
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
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › set-alias
Set-Alias (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
PS> Set-Alias -Name np -Value C:\Windows\notepad.exe PS> Get-Alias -Name np CommandType Name ----------- ---- Alias np -> notepad.exe · The Set-Alias cmdlet creates an alias in the current PowerShell session.
Discussions

how to set alias permanently on Windows 11 (coming from Linux)
In PowerShell, an alias has a different meaning from an alias in Linux. What you are looking for in PowerShell is a function, like this: function sqlstart { net start postgresql-x64-16 } function sqlstop { net stop postgresql-x64-16 } These can be entered into your profile, which runs at the start of every session, just like a .bashrc or .bash_profile does. Type $PROFILE on your commandline to see the path. If the path doesn't exist yet, you can force create it with New-Item $PROFILE -Force. That's all you need to do. To continue with some background info on aliases, an alias in PowerShell is a shortened label for a command or parameter. It doesn't encompass an expression like the entire set of a command and its arguments; that would be a function. An example of an alias would be ni $PROFILE -f, which is the same New-Item command above, but now the command is using the built-in alias ni, and -Force has been shorted to -f, taking advantage of the fact that PowerShell will always autocomplete a parameter if there is only 1 possible completion available. More on reddit.com
🌐 r/PowerShell
15
15
January 1, 2025
How to add a path shortcut in Powershell?
Well something you could do would be to add some variables with those locations into your PowerShell profile. Then all you would have to do is cd $location. So, it would look something like this. $location1 = "C:\users\whatsit\desktop" $location2 = "C:\users\whatsit\documents\stuff" cd (or set-location since cd is an alias after all) $location1 More on reddit.com
🌐 r/PowerShell
15
28
November 30, 2019
The PowerShell Alias just won't stick!!
PowerShell is case insensitive so by defining an alias using the same value as the function it's going to alias UpdateAll with the alias which then fails with the error you've seen. In your case you don't need the alias as the function can be called like updateall or any other case permutation. Function TestFunction { 'foo' } Set-Alias -Name testfunction -Value TestFunction # Both of these now fail because of the recursive alias testfunction TestFunction More on reddit.com
🌐 r/PowerShell
3
7
June 6, 2024
Not able to set an alias
I guess a function will help you with that: https://stackoverflow.com/questions/2677528/what-is-a-proper-way-to-pass-a-parameter-to-set-alias-in-powershell Add that tona custom ps profile and it will become permanent: https://docs.microsoft.com/en-us/previous-versions/technet-magazine/cc895642(v=msdn.10) More on reddit.com
🌐 r/PowerShell
11
6
June 11, 2022
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).

🌐
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 - Here is how to create a permanent Alias: Open your PowerShell profile. You can use the “notepad $PROFILE” command to open it in Notepad. Add the “Set-Alias” command to create your Alias.
🌐
PDQ
pdq.com › powershell › set-alias
Set-Alias - PowerShell Command | PDQ
To create a profile in the path ... aliases by using Export-Alias to copy the aliases from the session to a file, and then use Import-Alias to add them to the alias list for a new session....
🌐
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 - To make an alias permanent, you need to add it to your shell's configuration file, such as .bashrc or .bash_profile. ... Open a terminal. Open your .bashrc file in a text editor. You can do this with nano or vi ... Save and close the text editor. ... Setting aliases in PowerShell and Bash can ...
🌐
Baldbeardedbuilder
baldbeardedbuilder.com › blog › adding-command-aliases-to-power-shell
Adding command aliases to Powershell
I’m not going to go into detail on how to write PowerShell functions or options for parameters. There are plenty of resources out there for the two. But hopefully this showed you a rudimentary way to set up command aliases for PowerShell. Just add the code to your PowerShell profile.ps1 and ...
Find elsewhere
🌐
4sysops
4sysops.com › home › blog › powershell tutoiral › how to create a powershell alias
How to create a PowerShell alias – 4sysops
July 28, 2023 - That means you cannot alias long, multi-command strings or even add parameters. Doing so will cause the command to fail. The solution, ironically, is to use functions. So, to edit your profile with “edss,” you need to define a function first and then alias the function. Function Edit-PowerShellProfile {notepad $profile} New-alias edal Edit-PowerShellProfile Your profile is <your user ID path>\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1
🌐
Microsoft Learn
learn.microsoft.com › en-us › powershell › module › microsoft.powershell.utility › new-alias
New-Alias (Microsoft.PowerShell.Utility) - PowerShell | Microsoft Learn
This command creates an alias named C to represent the Get-ChildItem cmdlet. It creates a description of "Quick gci alias" for the alias and makes it read-only. New-Alias -Name "C" -Value Get-ChildItem -Description "Quick gci alias" -Option ReadOnly Get-Alias -Name "C" | Format-List *
🌐
ServerWatch
serverwatch.com › home › guides
PowerShell Aliases | Create Alias for PowerShell cmdlet
March 12, 2021 - In the PSConfiguration folder, create a file named “Microsoft.PowerShell_Profile.PS1.” This file will hold the PowerShell commands to create aliases. Next, add the following PowerShell commands to create aliases in the file.
🌐
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 - Set-Alias -Name mkstart -Value "minikube start" Set-Alias -Name mkprofls -Value "minikube profile list" Set-Alias -Name mkprof -Value "minikube start --profile=" 3. Save and close the file. Now start a new PowerShell session or run the script using this: ... In case you encounter the following error while executing the script, you can check the execution policy with the cmmand Get-ExecutionPolicy If the output is Restricted, then the policy needs to be changed.
🌐
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>.
🌐
GitHub
gist.github.com › timsneath › 19867b12eee7fd5af2ba
PowerShell template profile: adds some useful aliases and functions · GitHub
Save timsneath/19867b12eee7fd5af2ba to your computer and use it in GitHub Desktop. Download ZIP · PowerShell template profile: adds some useful aliases and functions · Raw · profile.ps1 · This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below.
🌐
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 › @rehan.janjua › configure-a-powershell-alias-7bcacdb69f08
Configure a PowerShell Alias. An alias is a reference to program or… | by Rehan Janjua | Medium
August 13, 2024 - $PROFILE | Select-Object * AllUsersAllHosts : C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 AllUsersCurrentHost : C:\Windows\System32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 CurrentUserAllHosts : C:\Users\username\OneDrive\Documents\WindowsPowerShell\profile.ps1 CurrentUserCurrentHost : C:\Users\username\OneDrive\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 · In this example, we will create an alias for terraform.exe for “CurrentUserCurrentHost” along with a function to open a web browser to the specified URL.
🌐
TutorialsPoint
tutorialspoint.com › how-to-create-powershell-alias-permanently
How to create PowerShell alias permanently?
February 14, 2020 - Here, we will create a profile ... will open the file to allow the user to manipulate. Once a file is opened, edit the file to set your aliases....
🌐
GitHub
github.com › hackf5 › powershell-profile-alias
GitHub - hackf5/powershell-profile-alias: Bash style aliases in PowerShell · GitHub
Haven't you ever wanted to write bash aliases in PowerShell? You know, like all the cool kids do on their overpriced Mac books with the stickers on them that say things like Reagan Bush '84? ... > Set-ProfileAlias laws -Command (-join( 'docker run --network crypto_crypto-net --rm -it ', '-v $env:userprofile\.aws\\localstack:/root/.aws amazon/aws-cli ', '--endpoint-url=http://localstack:4566 #{*}')) -Bash > laws sqs list-queues QueueUrls: - http://localhost:4566/000000000000/my_queue - http://localhost:4566/000000000000/queue1
Starred by 49 users
Forked by 3 users
Languages   PowerShell
🌐
Seb Nilsson
sebnilsson.com › blog › powershell-profile-with-permanent-aliases
PowerShell Profile with Permanent Aliases - Seb Nilsson
September 17, 2014 - %UserProfile%\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 · When you've ensured that this file is created you can enter PowerShell-scripts that will run every time you open your PowerShell-console. Ensure that your execution policy is configured to support this: ... For example you can create a PowerShell-alias for the git-command to work with just using g instead:
🌐
Medium
medium.com › tomtalkspowershell › using-aliases-for-powershell-commands-what-you-need-to-know-dd34b6032fcd
Using Aliases for PowerShell Commands: What You Need to Know | by Tom | TomTalksPowershell | Medium
November 29, 2024 - Open the profile with a text editor (e.g., notepad $PROFILE), and add the alias command. Save and close the editor. ... This project will help you understand how to create aliases and work with the PowerShell profile.
🌐
Delft Stack
delftstack.com › home › howto › powershell › powershell alias
How to Create Aliases in PowerShell | Delft Stack
February 2, 2024 - Inside the PSConfiguration folder, create a file named Microsoft.PowerShell_Profile.PS1. This file will contain the Windows PowerShell cmdlets to create aliases. Next, add the PowerShell commands to create aliases in the file.