当我在PowerShell中键入dir时,我想看到彩色的文件名。 所以,我从这里添加了Set-ChildItemColor函数到我的configuration文件。 我还在configuration文件的末尾添加了这行以覆盖目录别名:
Set-Alias dir Get-ChildItemColor
现在,当我打开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
这是什么AllScope ? 如何删除该选项以获得彩色目录?
使用Set-Alias的-Option参数。
Set-Alias -Name dir -Value Set-ChildItemColor -Option AllScope
有关详细信息,请参阅Get-Help Set-Alias和Get-Help about_Scope。