Search code examples
powershellalias

How do I remove or replace a built in alias in powershell?


Powershell includes a built-in alias diff for the Compare-Object cmdlet. This is really annoying for me, as I'm used to using the Unix diff command.

Is there a way to remove the built in diff alias, or otherwise override it?

I've tried:

  • del alias:diff - gives an error "Alias was not removed because alias diff is constant or read-only"
  • set-alias diff diff.exe - gives an error similar to the above
  • function diff { diff.exe $args } - the alias takes precedence

How do I get access to the "real" diff (without having to remember a different name)?

In case it matters, this is Powershell 3. I haven't tried it in version 4 yet, although version 4 also has a wget alias, but unlike diff I could remove that one...


Solution

  • Try removing if forcefully.

    del alias:diff -Force