I manage my profile as a module, for some reason I'd like to remove default md alias, and use my md function instead:
# in a module file
if (Test-Path alias:md) {
Remove-Alias md -Scope Global
}
# my md impl
function md {
$null = New-Item -ItemType Directory @args
}
But it didn't work, I still have md alias in session, it seems aliases with option AllScope can't be deleted from within a module? I can confirm that alias with option None can be deleted successfully
EDIT: add example to reproduce the problem
New-Module { Remove-Item alias:md }
Get-Command md # md still exists
New-Module { Remove-Item alias:wjb }
Get-Command wjb # would error, wjb was removed as expected