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 abovefunction diff { diff.exe $args }
- the alias takes precedenceHow 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...
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.
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.
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.
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.
Try removing if forcefully.
del alias:diff -Force
For Windows 10 1803 build 17134 it only removes a constant alias for the current window even if -Force is used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With