Getting to Know the Three Key Pillars of PowerShell for Windows Administration – Cmdlets, Objects, and Pipelines

PowerShell is a command-line and scripting platform designed to assist system administrators in managing and automating tasks in a Windows environment.

Built on the .NET Framework, PowerShell has better capabilities than the traditional command line. It supports Cmdlets, objects, and pipelines, which allow users to perform complex tasks with ease.

PowerShell is a very important tool in Windows administration. With the existing features, administrators can:

  • Manage systems more efficiently without the need to use graphical interfaces.
  • Automate routine tasks such as service management, system setup, or performance monitoring.
  • Reduce the chances of human error by using standardized scripts.

PowerShell not only increases productivity but also provides more flexibility to solve problems directly, even in large and complex system environments. This makes it a go-to tool for modern administrators who need a quick and precise solution.

What is Cmdlets?

Cmdlets are small programs that are created to perform specific tasks in PowerShell. They serve as a tool to manage and automate various aspects of the Windows operating system.

Cmdlets are written in the form of .NET classes, usually using the C. Cmdlets can be included in PowerShell or be part of other applications and services, such as VMware or Windows Server features. With cmdlets, users can easily retrieve information, change settings, and perform various other operations.

Examples of Popular Commands

Two examples of commonly used cmdlets are:

1. Get-Process

These cmdlets are used to get information about all the processes that are running on the system. For example, running the following command will display a list of all active processes:

Get-Process

2. Get-Service

These cmdlets are used to get information about all the services listed in the system. With this command, the user can see the status of the service (whether running or stopped):

Get-Service

Advantages of Using Noun-Verb Syntax in Cmdlets

One of the standout features of cmdlets is the strict use of noun-verb syntax. This means that each cmdlet is named with a clear pattern, where the first part (noun) indicates the managed object and the second part (verb) indicates the action performed on the object. Examples:

  • Get: Retrieving information.
  • Set: Change the configuration.
  • Remove: Delete an object.

Advantages of this syntax include:

  • Users can easily find other relevant cmdlets by understanding the naming pattern.
  • Consistent syntax helps new users to learn and use cmdlets more quickly.
  • Clear cmdlets names make scripts easier to read and understand.

Objects in PowerShell

In PowerShell, an object is a data structure that describes a specific entity in a system, such as a file, process, or service. Each object has properties (attributes) and methods (methods) that provide information and functions related to that entity.

Properties are the characteristics of an object, while methods are actions that can be performed on an object. For example, a process object can have properties such as process name, CPU usage, and status.

How Get-Process Generates Objects with Properties Like CPU Usage

When you run the Get-Process cmdlet, PowerShell generates an object that represents all the processes that are active on the system. Each of these process objects has various properties, including:

  • Name: The name of the process.
  • Id: Unique identification for the process.
  • CPU: CPU usage by processes.

Example command:

Get-Process

This command will give you a list of process objects, and if you want to see more information about one of the objects, you can use the Get-Member cmdlet to find out the properties and methods that exist:

Get-Process | Get-Member
powershell Get Process

This will display all the properties and methods of the object generated by the Get-Process, including CPU usage.

Latest Articles