I just ran into something useful but apparently esoteric as it's non-standard use of Get-Content; specifically: Get-Content Function:\mkdir
. When I use this command in Powershell, it returns the entire function definition, and even the function body. Oddly enough, Get-Content Function:\ipconfig
does not, even though it's listed literally alongside mkdir on the official documentation.
I've been studying ways of easily finding more info on cmdlets, object definitions, etc. in Powershell. This particular seems rather useful, however, it's hard to find more use of Get-Content in this context, as it's usually used somewhat differently.
It makes sense because md
is an alias of mkdir
and mkdir
is a function. If you target the alias:
provider then it will resolve into the command it's pointing to:
Get-Content alias:\md
In this case, I'd recommend to use Get-Command
instead if you're looking for the source code of a function.
$command = Get-Command md
$command -is [System.Management.Automation.AliasInfo] # True
$command.ResolvedCommand # mkdir
$command.ResolvedCommand.ScriptBlock # source code for mkdir
After updates to the original question the above answer doesn't make any sense. The original question was asking about an alias, and now the update is asking about an actual application (ipconfig
) which of course there is no content to get because 1. Applications don't belong to the function:
provider and 2. The source code is compiled.