Skip to content

Instantly share code, notes, and snippets.

@thoughtful-solutions
Created August 8, 2024 08:48
Show Gist options
  • Save thoughtful-solutions/ffe26aa0d71266428aa3b75dc33634ea to your computer and use it in GitHub Desktop.
Save thoughtful-solutions/ffe26aa0d71266428aa3b75dc33634ea to your computer and use it in GitHub Desktop.
Windows Aliases via CMD or BAT files

Windows Aliases

It can be very useful to build aliases quickly for windows hosts. This can be done effectively with a CMD/BAT file

Example

This executes a command and if there are parameters passed to the command then they are added to the command

C:\Users\msn\AppData\Local\Microsoft\WindowsApps>more azrg.bat
@echo off
set "command=az resource list --query "[].{name:name, type:type, resourceGroup:resourceGroup, location:location}""

set "args=%*"

if defined args (
    set "command=%command% %args%"
)

%command%

Placement

Theses CMD/BAT files need to be within the search path. Typically I place them in C:\Users\%USERNAME%\AppData\Local\Microsoft\WindowsApps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment