Getting Started with PowerShell

In this short guide we are going to learn how to check, install or update or PowerShell installation as well as how to start using it. Let’s get started!

What We'll Learn:

Welcome!
This short guide is all about aliases in windows PowerShell.

  • We will start by learning exactly the alias provider is.
  • We will then learn how to view information on all our aliases.
  • And finally, how to create our very own aliases and how to delete them.

Lets get started!

What are Aliases?

PowerShell cmdlet names follow a VerbNoun convention which sometimes can be cumbersome to type.
To minimize typing and make it easier for users who are familiar with other shells such as the command prompt, PowerShell supports aliases.

In simple terms, an alias is an alternative name for a cmdlet, function, executable, script, and so on.

List/View Aliases (Get-Alias):

PowerShell includes a set of built-in aliases, to view them type Get-Alias in your PowerShell console.
Get-Alias
All the aliases that are available in the current PowerShell session will be displayed at once.If you are familiar with any other shells such as the command line or Unix, you will notice that PowerShell includes many aliases that can make your transition to PowerShell much easier. Such as the “dir” command from the windows command line which is an alias for the Get-Childitem cmdlet or “Cat” from the Unix operating systems which is an alias for the Get-Content cmdlet.While the equivalent cmdlets may not function exactly the same way, they are close enough that you can do work without knowing the corresponding cmdlets.

Aliases as Abbreviations:

Aliases can also be abbreviations of cmdlets, for example the “cp” alias is an abbreviation for the Copy-Item cmdlet.

These types of aliases can save you heaps of time by reducing the amount of typing you have to do. Scroll through the output of the get-alias command and discover a few aliases on your own.

Creating Aliases (New-Alias):

While there are plenty built-in aliases, you might want to create a few aliases on your own. To do so you will need to use the New-Alias cmdlet.
For example let’s say that we want to create an alias for viewing our network adapters, the cmdlet for that is Get-NetAdapter, so to create our alias use the new-alias cmdlet followed by the -name parameter, the name of the alias within quotes, along with the -value parameter and the name of the cmdlet.
Here is what that would look like:

New-Alias -Name “na”-Value Get-NetAdapter

An alias with the name “na” for the Get-NetAdapter cmdlet has been created successfully. Let’s try using it.

Na

The alias should be working as if you had typed the cmdlet itself.

The parameters of the cmdlet can be used as well without any complications. For example, we can use the -physical parameter with our alias to display only physical adapters the same way we would on the cmdlet itself.

Keep in mind that by default, aliases that we create will only work in our current session, however our aliases can be made permanent by using a PowerShell profile. We are going to learn more about PowerShell profiles in the following posts.

Removing Aliases:

To remove an alias you created by mistake or that you no longer need, use the remove-item cmdlet.

The remove-item cmdlet is not made for deleting aliases exclusively, but rather, as the name suggests, it removes items in general, that’s why we have to specify the type of item we want to remove, in this case an alias.
So, to remove our alias type the remove-item cmdlet followed by the word alias directly followed by a colon and the name of the alias within quotes.

Remove-Item alias:”na”

Optionally you can try typing the name of your alias once more, to verify that it has indeed been removed.

Summary:

  • PowerShell is an extremely powerful tool and it hosts a myriad of useful features and tools.
  • Launching it is quite easy, simply search for PowerShell 7 and select the first result, just like we learned.
  • If you are not using the latest version, make sure you check and upgrade your installation.

That's It!

You now know how to begin working with PowerShell and are ready to start working with it.

If you liked this short guide take a look at a few of our other posts related to the windows command line, or if you really liked it consider enrolling in our video course where you will learn the ins and outs of the Windows PowerShell.

Windows PowerShell

Dont Stop Learning!

Windows PowerShell Course

Learn the ins and outs of Windows PowerShell along with PowerShell scripting and become an expert!

Read More:

Comments:

Leave a Reply

Your email address will not be published.

Take Your Skills to the next level!

Become one of our beloved students by enrolling into one of our courses. Get started now!