当我在 Powershell 中输入 dir 时,我想看到彩色的文件名。所以,我从这里将Set-ChildItemColor函数添加到我的配置文件中。我还在配置文件的末尾添加了这一行来覆盖 dir 别名:
Set-Alias dir Get-ChildItemColor
Run Code Online (Sandbox Code Playgroud)
现在,当我打开 Powershell 时,出现此错误:
Set-Alias : The AllScope option cannot be removed from the alias 'dir'.
At C:\Users\joe\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:82
char:10
+ Set-Alias <<<< dir Get-ChildItemColor
+ CategoryInfo : WriteError: (dir:String) [Set-Alias], SessionStateUna
uthorizedAccessException
+ FullyQualifiedErrorId : AliasAllScopeOptionCannotBeRemoved,Microsoft.PowerShe
ll.Commands.SetAliasCommand
Run Code Online (Sandbox Code Playgroud)
这是什么AllScope?如何删除该选项以获得彩色目录?
小智 28
使用 Set-Alias 的 -Option 参数。
Set-Alias -Name dir -Value Set-ChildItemColor -Option AllScopeRun Code Online (Sandbox Code Playgroud)
有关详细信息,请参阅 Get-Help Set-Alias 和 Get-Help about_Scope。
| 归档时间: |
|
| 查看次数: |
3946 次 |
| 最近记录: |