Lead Image © Philip Kinsey, 123RF.com

Lead Image © Philip Kinsey, 123RF.com

Working with objects in PowerShell

Useful Tool

Article from ADMIN 39/2017
By , By
This workshop helps admins understand the object-oriented structure of PowerShell.

If you want to professionally manage Windows systems, and above all servers, it's hard to avoid using PowerShell. Many admins, however, find it somewhat difficult to cope with the object-oriented approaches of the scripting language. Our workshop provides assistance and illuminates the fundamental concepts.

Of course, admins use scripting languages to handle administrative and support tasks, and many system administrators will have had no alternative but to delve the depths of the SQL language. Basically, most administrators want to do their jobs rather than develop programs, which explains why many experienced Windows admins have a certain aversion to working with PowerShell. This is particularly unfortunate, because this language can significantly facilitate the work, specifically because of its structure and object-oriented approach (see the "Object-Oriented Structure in PowerShell" box for more information). The motivation behind this article is thus to show how the developers implemented this concept and how the scripting language uses these objects.

Object-Oriented Structure in PowerShell

The foundation of PowerShell comprises special .NET classes that make it possible to use the entire .NET library from within the PowerShell environment. The cmdlets available directly in the PowerShell environment run perform specified actions, such as enumerating the files in a directory or managing a system service.

The cmdlets for PowerShell objects typically return objects, although there are some exceptions. The cmdlets perform an action of this type by creating an object or a group of objects based on the specialized PowerShell classes. They then provide the functions available, with the help of which, for example, the information can be routed through the pipeline and used by other commands.

Often the problem for

...
Use Express-Checkout link below to read the full article (PDF).

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy ADMIN Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Comparing PowerShell and Python
    Although PowerShell has its ardent advocates, many admins and users swear by Python, especially for Windows. Which scripting language is best for you? Read on for a comparison of PowerShell and Python.
  • PowerShell Part 1: Retrieving System Information

    Windows administrators, like Unix or Linux administrators, look for ways to perform their duties with ease and elegance through automation. PowerShell allows administrators to gather information, change Registry parameters, work with Active Directory, manipulate services, look at events, work with Windows Management Instrumentation (WMI), and much more. PowerShell is a Windows administrator’s best friend.

  • Software inventory with PowerShell
    PowerShell easily combines different interfaces for querying or reporting data.
  • Platform independence with PowerShell Core
    Microsoft has broken new ground with the release of PowerShell Core 6.0, which at heart is a complete reboot in terms of architecture and objectives. For the first time, a new version is not linked to the Windows operating system.
  • Features of PowerShell loops
    Optimize your PowerShell scripts with loops when automating tasks that are repeated regularly and frequently.
comments powered by Disqus