October 16th, 2019

PowerTip: Use New-Alias to make Cmdlets easier to remember

Doctor Scripto
Scripter

Summary: Using New-Alias to create easier to remember shortcuts to Cmdlets in PowerShell

A picture containing scissors

Description automatically generated

Hey, Doctor Scripto. I know I can use Install-Module to download a DSC Resource, but is there some way to build a Cmdlet that does the Exact same job but call it Install-DSCResource? I would find that easier to remember when getting them (DSCResources).

We can’t create a new Cmdlet, but we can create an Alias. It will respond to all the same parameters as the original. To make an Alias of Install-Module that says Install-DSCResource just execute the following line.

New-Alias -Name Install-DSCResource -value Install-Module -description ‘Alias for Install-Module’

PowerShell, Doctor Scripto, PowerTip, Sean Kearney

 

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.