Retrace will reach End of Life on March 31, 2027. Click here to learn more.

What are PowerShell Commands? Understanding PowerShell’s Cmdlets with Code Examples, Tutorials, and More

By: Alexandra
  |  April 19, 2017
What are PowerShell Commands? Understanding PowerShell’s Cmdlets with Code Examples, Tutorials, and More

Definition of PowerShell

PowerShell is the shell framework developed by Microsoft for administration tasks such as configuration management and automation of repetitive jobs. The term ‘PowerShell’ refers to both – the shell used to execute commands and the scripting language that goes along with the framework.

The scripting aspect of it is similar to Perl programming. The shell is comparable to bash in UNIX, with Microsoft even incorporating commands such as man, ls, and ps for convenience.

PowerShell 1.0 was released in November 2006 for Windows XP SP2, Windows Server 2003 SP1 and Windows Vista. While, initially, PowerShell had to be manually installed, the latest version 5.0 is available default with Windows 10. So, you can just go to Cortana and type ‘PowerShell’ or navigate from the Start menu.

PowerShell also comes with an Integrated Scripting Environment (ISE). The ISE screen is split into two parts – the top one is used to write the script and the bottom for running commands manually. The ISE gives you a GUI experience, with smart syntax suggestions, coloring, tab completion and error handling.

If you are a Windows administrator who has to perform user management, DNS configurations and other tedious tasks frequently, PowerShell is the tool for you.

Benefits of PowerShell over Command Prompt

Well, PowerShell certainly has more power! Command prompt is an interface available to execute simple DOS commands; most users have not explored it beyond ping, ipconfig or in the programming world, ftp. However, PowerShell is much more than that. While there are many differences between the two, here are a few important ones:

  1. PowerShell uses cmdlets, not commands. Now, cmdlets are not just a different way of calling the same thing, but they expose complex system administration functionalities such as registry management and Windows Management Instrumentation (WMI) to the user. This makes them far more useful than the command prompt.
  1. PowerShell is object-oriented. The data output from cmdlets are objects (an example of how object-orientation makes PowerShell attractive) and not just text. This provides more flexibility to play around with complex data.
  1. PowerShell is developed using the .NET framework. This allows PowerShell scripts to use .NET interfaces and extend features that are not provided by default through cmdlets. The other way around is also possible – embedding PowerShell scripts in .NET code.

More About Cmdlets

Cmdlets are lightweight commands used in the PowerShell environment. Most of the cmdlets in PowerShell use the Verb-Noun format.

For example, Get-Command, Update-Help, Start-Service, etc.

To know more about cmdlets and understand what differentiates them from commands, you can read this link. One of the fundamental differences that we will discuss below is its object orientation – it reads input from a pipe and outputs objects (not text) to a pipe.

PowerShell Cmdlet Examples

Let’s go through an example to understand how this works.

On the command line, when you run the Get-Service cmdlet, you get a list of services on your machine.

PowerShell Commands

You can further filter these just to show the services that are running:

Get-Service | Where-Object {$_.Status –eq “Running”}

PowerShell Commands

Here, PowerShell processes every record output that GetService throws evaluate whether the ‘Status’ attribute is ‘Running’, and filters accordingly.

Note: $_ refers to the current record/object in the pipe.

One thing this example shows is the cmdlet’s record-oriented feature. The processing of one record at a time gives the flexibility to interpret data in a more intelligent way than it would be possible with text streams.

You can filter the previous output further, to just display the ‘Name’ of the running services.

Get-Service | Where-Object {$_.Status -eq “Running”} | Select-Object Name

PowerShell Commands

To learn more about any command, use

Get-Help –Name <Cmdlet name>

Or Get-Help –Name <Cmdlet name> -Online

The latter opens up detailed help with examples on the msdn site.

Here, you can learn some basic commands to get you initiated into PowerShell. If you are a visual person, go for this video. For a detailed list, this would help.

Quick Intro to Aliases

Aliases are alternate names for your cmdlets. These are usually handy for frequently used commands and when you don’t want to type the whole Verb-Noun format. For example, Get-Command has an alias ‘gcm’, Get-Service has ‘gsv’, Where-Object has a simple ‘?’.

Many UNIX commands are set up as aliases by default. For example, cat->Get-Content, man->help, ps->Get-Process, etc.

Run Get-Alias to see the complete list of aliases available in PowerShell.

Of course, you can create your own aliases as well.

Creating a PowerShell Script

To create a PowerShell script, all you have to do it open a file, write your code and then save it. PowerShell scripts have a .ps1 extension. Your script can then be run manually or automated to run as a job every day to perform administration tasks. Get started here for creating simple scripts with looping and conditions.

Tutorials and Resources on PowerShell Commands (Cmdlets)

Through PowerShell commands and scripts, there is so much benefit to be gained for an IT administrator. Here is a list of use cases where an administrator can leverage PowerShell commands. From gathering information about servers to managing folders, processes, services, memory, network, software installations, and registries, there are tons of features that PowerShell encapsulates. Not to forget about its seamless integration with .NET.

Once you get over the initial learning curve, you can start exploiting the functionalities of PowerShell. When you’re ready to explore further, check out the following tutorials and resources:

Improve Your Code with Retrace APM

Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.

Learn More
indobet toto slot toto toto bobatoto daftar logototo patentoto toto bayitoto popotogel prize hongkong malam ini joker11 lingkartoto depo 5k slot sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot jepang https://www.juara288.asia/ slot 4d toto toto situs toto flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot bobatoto kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d slot gacor bento11 link slot gacor toto toto slot toto situs slot situs slot situs slot https://www.asupan188.dev/ slot gacor gampang menang toto slot gacor bwo303 situs toto toto slot slot gacor slot88 slot gacor situs slot link slot slot gacor pucuk4d PASCOL4D situs slot link slot slotvip situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 situs slot link slot situs judi bola POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat link slot slot gacor situs slot slot gacor slot gacor situs slot link slot gacor Slot88 Slot88 slot gacor situs toto toto slot pulsa slot777 link slot gacor situs gacor slot gacor slot gacor slot gacor slot gacor Slot88 slot gacor situs slot slot gacor Slot88 slot gacor slot terbaru slot gacor situs gacor situs slot slot gacor situs slot Situs Slot POPOTOGEL: Regulasi Bandar Situs Togel Resmi & Bola Mix Parlay Asia Terpercaya StreamEast Jpmania slot resmi slot slot resmi slot bayitoto patentoto link gacor slot gacor kari4d slot gacor slot gacor slot gacor AMANAHTOTO pascol4d kari4d AMANAHTOTO kari4d bragatoto dokter88 slot gacor slot game patentoto pucuk4d rokokbet rokokbet kari4d pascol4d LOGIN PASCOL4D pucuk4d roma77 judi bola slot depo 10k mpo slot Girang4d KARI4D StreamEast AMANAHTOTO jutatoto PARLAY slot88 slot depo 5k hoki99 pascol4d pkv games roma77 Slot poker slot
indobet toto slot toto toto bobatoto daftar logototo patentoto toto bayitoto popotogel prize hongkong malam ini joker11 lingkartoto depo 5k slot sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot jepang https://www.juara288.asia/ slot 4d toto toto situs toto flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot bobatoto kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d slot gacor bento11 link slot gacor toto toto slot toto situs slot situs slot situs slot https://www.asupan188.dev/ slot gacor gampang menang toto slot gacor bwo303 situs toto toto slot slot gacor slot88 slot gacor situs slot link slot slot gacor pucuk4d PASCOL4D situs slot link slot slotvip situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 situs slot link slot situs judi bola POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat link slot slot gacor situs slot slot gacor slot gacor situs slot link slot gacor Slot88 Slot88 slot gacor situs toto toto slot pulsa slot777 link slot gacor situs gacor slot gacor slot gacor slot gacor slot gacor Slot88 slot gacor situs slot slot gacor Slot88 slot gacor slot terbaru slot gacor situs gacor situs slot slot gacor situs slot Situs Slot POPOTOGEL: Regulasi Bandar Situs Togel Resmi & Bola Mix Parlay Asia Terpercaya StreamEast Jpmania slot resmi slot slot resmi slot bayitoto patentoto link gacor slot gacor kari4d slot gacor slot gacor slot gacor AMANAHTOTO pascol4d kari4d AMANAHTOTO kari4d bragatoto dokter88 slot gacor slot game patentoto pucuk4d rokokbet rokokbet kari4d pascol4d LOGIN PASCOL4D pucuk4d roma77 judi bola slot depo 10k mpo slot Girang4d KARI4D StreamEast AMANAHTOTO jutatoto PARLAY slot88 slot depo 5k hoki99 pascol4d pkv games roma77 Slot poker slot