In Windows PowerShell, the alias md
relates to the definition mkdir
, which also seems to be an alias (i.e. not a Verb-Noun definition.) as this command indicates:
: get-item -path alias:* | where-object {$_.Definition -eq "mkdir"}
CommandType Name
----------- ----
Alias md -> mkdir
An alias is an alternate name for a cmdlet, function, executable file, including scripts. PowerShell includes a set of built-in aliases. You can add your own aliases to the current session and to your PowerShell profile. The Alias drive is a flat namespace that contains only the alias objects.
Creates a directory or subdirectory. Command extensions, which are enabled by default, allow you to use a single mkdir command to create intermediate directories in a specified path. This command is the same as the md command.
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.
PowerShell's Get-Command
cmdlet allows you to reflect on command names:
PS> Get-Command md
CommandType Name Version Source
----------- ---- ------- ------
Alias md -> mkdir
This tells you that md
is an alias and that it resolved to a command named mkdir
.
PS> Get-Command mkdir
CommandType Name Version Source
----------- ---- ------- ------
Function mkdir
This tells you that mkdir
is a function.
To see that function's definition (function body), access the .Definition
property on the object returned by Get-Command
:
(Get-Command mkdir).Definition # outputs the function's body
The output of the above will tell you that mkdir
is a proxy function for New-Item -ItemType Directory
.
In other words: it provides a file-system-specific shortcut for creating directories to the more generic New-Item
cmdlet - see Get-Help about_Providers
to learn about PowerShell's generalization of the concept of drives.
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