0

I'm quite new in this terminal topic, I'm using Windows PowerShell and I was trying to solve a Postgres bug.

I checked out some posts here that solved the problem but I saw that people used "which" to look the directory of a file, I wrote it in my console and I the command doesn't work. The thing is that I'd searched how to use this command in PowerShell and I created it didn't work and every time I open PowerShell, this error message appears in my screen:

New-Alias : The alias is not allowed, because an alias with the name 'which' already exists.

  • New-Alias which get-command

  • CategoryInfo : ResourceExists: (which:String) [New-Alias], SessionStateException

  • FullyQualifiedErrorId : AliasAlreadyExists,Microsoft.PowerShell.Commands.NewAliasCommand

I want to fix this but I don't know how, I need help :(

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    The error message might be coming from [a powershell profile](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-7.1#the-profile-files), a script that runs at startup. They can be in ~4 different places, so check the link and see if you have them and if any of them contain the `new-alias` command. – TessellatingHeckler Oct 12 '21 at 19:20
  • To add to this^, you may want to change it to `Set-Alias`. – Abraham Zinala Oct 12 '21 at 19:21

1 Answers1

0

If there were two aliases for "which", Powershell would not know which one you mean in a script.

You can list existing aliases and remove them, then create it again with the value you want.

Get-Alias -Name which
Remove-Alias -Name which

There are some existing questions about permanently setting up a new alias and editing your profile. e.g. How to create permanent PowerShell Aliases

OwlsSleeping
  • 1,487
  • 2
  • 11
  • 19