Is this possible? I have tried this blog, but it doesn’t work.
I have a macrofile with about 50 or so
doskey macros, which is used in
I run something like:
doskey /exename=powershell.exe /macrofile=C:\macrofile.txt
doskey /exename=powershell.exe blah=echo blah
But trying the command
blah gives an error:
blah : The term ‘blah’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
If I list them with
doskey /macros:powershell.exe however, they’re all there.
Is there a way I can create 50 aliases in PowerShell to map to these macros? The
Set-Alias cmdlet doesn’t help much since the commands are more complex than calling a simple PowerShell cmdlet. There are posts that suggest creating functions in a .ps1 script, however, this would work only if I manually write 50 different functions for each of the 50 macros in the file. Also, this would involve maintaining two files – the macrofile for cmd and a PowerShell script which translates these into functions.
PSReadLine module (ships with PowerShell 5.0 or later) is not compatible with
doskey, which relies on the native console input functions. I tested on Windows 10/PowerShell 5:
PS C:\> Remove-Module PSReadLine
PS C:\> doskey /exename=powershell.exe g=Get-Location
PS C:\> g