![如何重置 powershell 中的所有别名](https://linux22.com/image/1614800/%E5%A6%82%E4%BD%95%E9%87%8D%E7%BD%AE%20powershell%20%E4%B8%AD%E7%9A%84%E6%89%80%E6%9C%89%E5%88%AB%E5%90%8D.png)
我最近将别名设置为非命令,因为我不知道如何使用设置别名。我想知道如何在不影响 powershell 自带的默认别名的情况下重置所有别名。
我尝试使用Remove-Alias
但它返回了这个错误:
PS C:\Users\me\Desktop\Projet\> Remove-Alias lua
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 lua
+ ~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Remove-Alias:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
答案1
在 powershell 5.x 下,remove-alias 不可用。因此您必须使用 remove-item。尝试以下操作:
Remove-Item Alias:lua
答案2
看 - -
Name Value
---- -----
PSVersion 5.1.18362.145
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.18362.145}
BuildVersion 10.0.18362.145
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
CommandType Name Version Source
----------- ---- ------- ------
...
Function Get-PSUPathAlias 2.0.8 PSUtil
Function Remove-PSFAlias 1.0.12 PSFramework
Function Remove-PSFAlias 1.0.2 PSFramework
Function Remove-PSUPathAlias 2.0.8 PSUtil
Function Set-PSFTypeAlias 1.0.12 PSFramework
Function Set-PSFTypeAlias 1.0.2 PSFramework
Function Set-PSUPathAlias 2.0.8 PSUtil
Cmdlet Export-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet Get-Alias 3.1.0.0 Microsoft.PowerShell.Utility
...
Cmdlet Import-Alias 3.1.0.0 Microsoft.PowerShell.Utility
Cmdlet New-Alias 3.1.0.0 Microsoft.PowerShell.Utility
...
Cmdlet Remove-Alias 5.0.0.1 Sorlov.PowerShell
...
Cmdlet Set-Alias 3.1.0.0 Microsoft.PowerShell.Utility
...
Find-Module -Name '*alias*'
Version Name Repository Description
------- ---- ---------- -----------
2.4 ResolveAlias PSGallery A function for cleaning up scripts by ...
1.0 posh-alias PSGallery A better alias for Powershell
0.1.0 PowerShell-Core-Compatibility-Alias PSGallery Adds aliases to PowerShell Core that w...
0.2.1 git-aliases PSGallery A PowerShell module that provide parti...
1.2 CommonAliases PSGallery Common aliases for easier use.
1.0 rg-ps-alias PSGallery Creates Alias for docker and git, see ...
0.1.1 GitAliases PSGallery Automatically configures aliases for a...
1.292 Office365MailAliases PSGallery This module contains functions to crea...