Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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...

like image 401
Paul Moore Avatar asked Jul 22 '14 08:07

Paul Moore


People also ask

How do I change an alias in PowerShell?

To change or delete a read-only alias, use the Force parameter. The Set-Alias cmdlet creates an alias in the current PowerShell session. The Name parameter specifies the alias's name, loc . The Value parameter specifies the Get-Location cmdlet that the alias runs.

How do I delete an alias in PowerShell?

To remove newly created aliases without closing the PowerShell console, you need to use RemoveAlias command. You can also use Del command to remove the alias. Again you cannot remove the Aliases which are permanent. Only newly created aliases can be removed and automatically deleted when the session ends.

Can we delete predefined alias in PowerShell?

The Remove-Alias cmdlet removes an alias from the current PowerShell session. To remove an alias with the Option property set to ReadOnly, use the Force parameter. The Remove-Alias cmdlet was introduced in PowerShell 6.0.

How do I delete an alias in PowerShell 365?

Use the Powershell cmdlet Set-Mailbox to check email aliases assigned to Office 365 accounts, add aliases or remove aliases. Additionally the handy form underneath will generate the correct Powershell commands for you.


2 Answers

Try removing if forcefully.

del alias:diff -Force
like image 177
Mohammad Nadeem Avatar answered Sep 27 '22 05:09

Mohammad Nadeem


For Windows 10 1803 build 17134 it only removes a constant alias for the current window even if -Force is used.

like image 1
Abbas Bhaijibhai Avatar answered Sep 26 '22 05:09

Abbas Bhaijibhai