Get started Bring yourself up to speed with our introductory content.

Build a Windows automation foundation with PowerShell objects

PowerShell newbies should start with the basics of Microsoft's automation management tool to learn how to develop their own scripts. A few lines of PowerShell code can replace inefficient point-and-click management. As administrators build their expertise in PowerShell, they can scale their code to manage hundreds -- or thousands -- of users.

PowerShell objects are important concepts for beginners to understand -- everything in PowerShell is built on these objects. A solid grasp of what objects are, how they work and how to manage them paves the way for admins to dive deeper into more advanced uses for PowerShell.

In the context of PowerShell objects, an administrator needs to understand two concepts: properties and methods. Think of an object like a car. It has certain features -- paint color, doors, wheels and an engine. These are the car object's properties. A car can also perform tasks -- drive forward and backward as well as start and stop. Think of these actions as the methods.

This video further explains PowerShell objects, how to view an object's properties and methods with the Get-Member cmdlet and how to invoke methods on objects. You'll also get a preview of the next video tutorial: the PowerShell pipeline.

PowerShell objects sample code

## What is an object?
## Properties (attributes of that object) and Methods
# (actions to perform on that object)
## Usually one object per line of output
## PowerShell usually only shows some of the properties by default though
Get-ChildItem -Path C:\
Test-Connection -ComputerName localhost -Count 2

## Send objects to the Select-Object command using
## the -Property * parameter to see all properties of all objects
Get-Service -Name EventLog
Get-Service -Name EventLog | Select-Object -Property *

## Methods
$service = Get-Service -Name wuauserv

## Exploring objects with Get-Member (looking for properties AND methods)
Get-Member -InputObject $service
Get-ADComputer -Filter * -Server DC | Get-Member

## EVERYTHING in PowerShell is an object.
$string = 'hello world'
$string | Get-Member
$one = 1
$one | Get-Member
## Objects are the key to the pipeline (another lesson)

## How does Stop-Service know what service to stop? It was never provided
## Output from Get-Service has a lot of properties. How does it know
## which one to use for the name?
Get-Service -Name wuauserv | Restart-Service

View All Videos