How to import the alias "ral" of Remove-Alias? #25887
Replies: 1 comment
|
Good find - this is exactly the situation with cmdlet-declared aliases plus manifest export lists. The You can confirm with: Get-Module Microsoft.PowerShell.Utility).ExportedAliases ral won't be there, while other exported aliases will. Since Import-Module -Alias can only select from aliases the module actually exports (as you noted), the intended way to get ral in your session is to create it yourself - the cmdlet exists, so it just works: Set-Alias ral Remove-Alias Put that in your PROFILE to have it everywhere: Add-Content $PROFILE "Set-Alias ral Remove-Alias" If you would rather fix it at the source (e.g. you maintain a fork), adding ral to the AliasesToExport list in Microsoft.PowerShell.Utility.psd1 would export it normally - worth suggesting to the team if you think it should ship that way. |
Uh oh!
There was an error while loading. Please reload this page.
In the binary module
Microsoft.PowerShell.Commands.Utility, the definition of theRemove-Aliascmdlet includes the aliasral:PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/RemoveAliasCommand.cs
Lines 12 to 14 in 411d5fe
The manifest module
Microsoft.PowerShell.UtilityhasMicrosoft.PowerShell.Commands.Utilityas a nested module, but it does not export the aliasral:PowerShell/src/Modules/Unix/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1
Lines 32 to 33 in 411d5fe
PowerShell/src/Modules/Windows/Microsoft.PowerShell.Utility/Microsoft.PowerShell.Utility.psd1
Lines 30 to 31 in 411d5fe
Is the alias intended only for internal use within
Microsoft.PowerShell.Utility, or how is it intended to be used? AFAICT, the-Aliasparameter ofImport-Modulecan only select from among aliases that are already exported.The cmdlet and the alias were added in #5143.
All reactions