How to create an alias in Powershell?

Asked

Viewed 31 times

2

I work with projects that use different versions of Node and want to create an alias for versions in Powershell.

Ex:

nvm-version-default nvm use 14.17.3
nvm-version-oldProject nvm use 12.20.0

1 answer

1

Example:

function Get-SystemBootTime{
      systeminfo | find "System Boot Time"
}

Set-Alias -Name bt -Value Get-SystemBootTime

Running the alias:

PS > bt
System Boot Time:          7/20/2021, 8:49:23 AM
  • Interesting, but when I close the terminal the Alias is not saved. function useNodeDefault{
 nvm use 14.17.3
}

Set-Alias -Name nvm-use-default -Value useNodeDefault -Scope Global

  • In this case you need to create a profile and add the alias to it. Powershell Profile

Browser other questions tagged

You are not signed in. Login or sign up in order to post.