Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

powershell can't use remove-alias

Tags:

powershell

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.

like image 636
Neo Avatar asked Jun 24 '19 04:06

Neo


People also ask

How do I change an alias in PowerShell?

To change or delete a read-only alias, use the Force parameter. The Set-Alias cmdlet creates an alias in the current PowerShell session. The Name parameter specifies the alias's name, loc . The Value parameter specifies the Get-Location cmdlet that the alias runs.

How do I permanently set an alias in Windows PowerShell?

To create an alias for a command, create a function that includes the command, and then create an alias to the function. To save the aliases from a session and use them in a different session, add the Set-Alias * command to your Windows PowerShell profile.

What is the default error action preference in PowerShell?

The default value of $ErrorActionPreference is Continue. When that is the setting, the appearance when running ForLoop. ps1 is the same as that shown in Figure 17-1.


1 Answers

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.

like image 114
Moerwald Avatar answered Sep 22 '22 07:09

Moerwald