How to override the default dir alias in Powershell?

Posted by Ashwin on Server Fault See other posts from Server Fault or by Ashwin
Published on 2012-11-27T03:11:01Z Indexed on 2012/11/27 5:09 UTC
Read the original article Hit count: 639

Filed under:
|

I wanted to see colorized filenames when I typed dir in Powershell. So, I added the Set-ChildItemColor function from here to my profile file. I also added this line at the end of the profile file to override the dir alias:

Set-Alias dir Get-ChildItemColor

Now, when I open Powershell, I get this error:

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

What is this AllScope? How do I remove that option to get colorized dir?

© Server Fault or respective owner

Related posts about powershell

Related posts about alias