Category: Powershell

Windows PowerShell’s If Statement

Introduction to The Windows PowerShell If Statement PowerShell’s ‘If’ statement comes under the umbrella of flow control.  Once you master the basic construction then you can increase its usefulness by appending, ‘Else’ and ‘ElseIf’ statements.  One of my favourite alternative strategies is to use ‘Switch‘. Topics for PowerShell’s If Statement …

Windows PowerShell Default Parameters

PowerShell 3.0 $PSDefaultParameterValues New in PowerShell 3.0 is the ability to control the default value of parameters such as Logname.  This technique, using a built-in variable called $PSDefaultParameterValues will save you typing if you spend a lot of time with a cmdlets such as Get-Eventlog. PowerShell Default Parameter Topics Refresher: …

PowerShell v3 Alias – New Commands

New Aliases in PowerShell v3 Version 3 introduces eleven new shortcuts for regular PowerShell cmdlets, for example 'sls' for Select-String.  However, the most interesting part of this page is the journey towards identifying those extra aliases in the latest PowerShell version. PowerShell New Alias Topics Get-Alias: Count List Each Alias’s …

PowerShell Function Get-WMIClass

How to Filter the WMI Classes My aim is to provide an easy way to search for a class amongst the 800+ WMI (Windows management instrumentation) objects. I will provide instructions for creating a Windows PowerShell function; in particular I want to highlight creating parameters. Guy's Get-WMIClass Function (Cmdlet) Planning …

PowerShell Loop Examples

Examples to Illustrate PowerShell Looping PowerShell provides a rich variety of looping techniques for applying a block statement to a series of items.  To automate a repetitive task learn the syntax for a ‘Foreach’ or ‘While’ loop. Basic PowerShell Examples Example 1:  Classic PowerShell Loop Example 2:  Foreach Loop with …

PowerShell Receive-Job

PowerShell Background Jobs The purpose of this cmdlet is to view the data stored in a PowerShell job.  Receive-Job works in conjunction with Start-Job, and you can troubleshoot with Get-Job. Windows PowerShell Receive-Job Topics The Relationship Between Start-Job and Receive-Job Example 1: List Events in the System Log Example 2: …