I’ve mentioned before that I love PowerShell, but I’m still trying to commit enough Cmdlets and aliases to memory that I can be immediately productive from a Powershell prompt without having to have a browser window open to the Powershell documentation on another monitor. Several of the Cmdlets may also be referenced through one or more aliases, and it’s rather cumbersome to discover what aliases are defined for a given Cmdlet.
I stumbled onto a bit of code that will find all aliases for a given Cmdlet which I put it into a script named Find-Alias. That will let me type the following:
PS C:\>Find-Alias Get-ChildItem
CommandType Name Definition
----------- ---- ----------
Alias dir Get-ChildItem
Alias gci Get-ChildItem
Alias ls Get-ChildItem
Here is the script code:
param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipeLineByPropertyName=$true)]
[string]$Command)
Process
{
get-alias | where-object {$_.Definition -match $Command}
}
Share
Posted by
Paul Parks on
13 November 2009, 10:27 pm
I’ve been hearing this a lot lately (you know who you are), so rather than pull all of you aside privately and give this lecture, I thought I’d do it once, publicly. You’re not running a DOS prompt.
When you click on that shortcut that says, “Command Prompt” in Windows XP, or you run cmd.exe from the “Run” box, you’re not starting a “DOS prompt.” What you are starting is a command line interface, or just “command line” if you prefer. If you haven’t actually run COMMAND.COM, it’s not DOS!.
So, please, next time don’t tell me to run your favorite utility “at the DOS prompt.” Let DOS rest in peace.
The first person to call Powershell a DOS prompt will get the lecture in real time.
Share
An API is an interface. Those of you that have worked with COM already know that once an interface is published, it can never, ever change. Ever. Not until the end of time. The reason is that some bit of code somewhere is going to be using that interface, and if you change it you’ve just broken that code. Of course, not changing an interface also means not deleting a portion of it.
Continue reading ‘An API is Forever’ »
Share