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
situs toto pucuk4d indobet toto slot slot depo 10k 8kuda4d toto toto toto bobatoto daftar logototo situs toto situs toto toto patentoto situs toto slot 4D situs toto toto ilmutoto bayitoto mawar800 login popotogel prize hongkong malam ini toto joker11 lingkartoto depo 5k panen100 semibola popo togel https://asupantoto.co/ slot pascol4d login pascol4d login sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot88 slot jepang slot depo 5k pucuk4d https://www.juara288.asia/ slot 4d RP888 toto toto pascol4d situs toto kari4d flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot nobu99 logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo bobatoto istanaslot rp888 www.pajaktoto.io kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d toto slot slot gacor bento11 link KARI4D PUCUK4D pascol4d situs slot toto slot titi4d slot gacor toto toto slot toto jinhoki situs slot situs slot situs slot AMANAHTOTO 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 slot88 situs toto MySlot188 SlotPoker188 slot gacor slot gacor pucuk4d PASCOL4D slot gacor situs slot link slot pentaslot SLOT GACOR AMANAHTOTO TOTO 4D pajaktoto slotvip toto togel situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 toto slot slot gacor situs slot link slot slot thailand patentoto situs judi bola situs toto roma77 slot jpmania toto228 RATU89 RUSIA777 slot gacor POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat PARLAY slot gacor slot gacor slot gacor link slot BUNGASLOT slot slot gacor situs slot slot gacor slot gacor sejukbos situs slot link slot slot gacor gacor gacor Slot88 Slot88 coloktoto toto slot slot gacor situs slot gacor situs toto slot gacor toto toto toto slot gacor slot88 slot777 slot pulsa ayamtoto StreamEast slot777 slot88 link slot gacor situs gacor slot gacor slot gacor toto slot slot gacor leon188 slot gacor bandarqq jpmania slot gacor slot gacor Slot88 https://ini777gold.com nenek188 slot gacor slot gacor slot gacor
situs toto pucuk4d indobet toto slot slot depo 10k 8kuda4d toto toto toto bobatoto daftar logototo situs toto situs toto toto patentoto situs toto slot 4D situs toto toto ilmutoto bayitoto mawar800 login popotogel prize hongkong malam ini toto joker11 lingkartoto depo 5k panen100 semibola popo togel https://asupantoto.co/ slot pascol4d login pascol4d login sbobet88 sbobet88 https://nolimithoki.dev/ dinasti33 slot slot88 slot jepang slot depo 5k pucuk4d https://www.juara288.asia/ slot 4d RP888 toto toto pascol4d situs toto kari4d flokitoto slot gacor logototo slot depo 5k bobatoto bobatoto bobatoto sontogel mpo slot situs toto slot situs slot nobu99 logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo logototo bobatoto istanaslot rp888 www.pajaktoto.io kari4d kari4d kari4d kari4d pascol4d pascol4d pascol4d toto slot slot gacor bento11 link KARI4D PUCUK4D pascol4d situs slot toto slot titi4d slot gacor toto toto slot toto jinhoki situs slot situs slot situs slot AMANAHTOTO 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 slot88 situs toto MySlot188 SlotPoker188 slot gacor slot gacor pucuk4d PASCOL4D slot gacor situs slot link slot pentaslot SLOT GACOR AMANAHTOTO TOTO 4D pajaktoto slotvip toto togel situs toto toto slot situs slot situs slot situs slot toto slot gacor slot777 toto slot slot gacor situs slot link slot slot thailand patentoto situs judi bola situs toto roma77 slot jpmania toto228 RATU89 RUSIA777 slot gacor POPOTOGEL : Situs Resmi Bandar Toto Togel Macau dengan Prediksi Gokil Pasti Akurat PARLAY slot gacor slot gacor slot gacor link slot BUNGASLOT slot slot gacor situs slot slot gacor slot gacor sejukbos situs slot link slot slot gacor gacor gacor Slot88 Slot88 coloktoto toto slot slot gacor situs slot gacor situs toto slot gacor toto toto toto slot gacor slot88 slot777 slot pulsa ayamtoto StreamEast slot777 slot88 link slot gacor situs gacor slot gacor slot gacor toto slot slot gacor leon188 slot gacor bandarqq jpmania slot gacor slot gacor Slot88 https://ini777gold.com nenek188 slot gacor slot gacor slot gacor