小编Ash*_*ppa的帖子

如何覆盖 Powershell 中的默认目录别名?

当我在 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?如何删除该选项以获得彩色目录?

powershell alias

22
推荐指数
1
解决办法
3946
查看次数

标签 统计

alias ×1

powershell ×1