14

When I enter in PowerShell:

Remove-Alias -Name someAlias

This error shows:

Remove-Alias : The term 'Remove-Alias' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Remove-Alias -Name someAlias
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Remove-Alias:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Note: someAlias is already in my alias list, I checked this.

Neo
  • 1,031
  • 2
  • 11
  • 27

1 Answers1

21

Powershell 5.1 docu of New-Alias:

Notes To create a new alias, use Set-Alias or New-Alias. To change an alias, use Set-Alias. To delete an alias, use Remove-Item.

So under Powershell 5.x you've to use Remove-Item. In stated in above comment Remove-Alias is only supported in PowerShell 6.

Check this stackoverflow answer how an alias is removed via Remove-Item.

Moerwald
  • 10,448
  • 9
  • 43
  • 83
  • Well, that is if you don't have another add-on module\function that provides it. For Example --- Find-Command -Name Remove-Alias | Format-Table -AutoSize;Get-Command -Name Remove-Ali* | Format-Table -AutoSize – postanote Jun 24 '19 at 06:29
  • You should explain at least a little about how to use Remove-Item in this answer instead of just linking to the other answer. I only skimmed this answer and tried running Remove-Item without realizing it actually deletes files. – still_dreaming_1 Aug 10 '22 at 16:46
  • TLDR `Remove-Item` removes files. `$Alias` is a PSDrive (`Get-PSDrive Alias`) which is a special data store. `Remove-Item Alias:MyAlias` will get rid of the alias on PSv5. – RiverHeart Jul 14 '23 at 19:19