Scripting Blog

A place to learn about PowerShell and share stories of automation

PowerShell for Programmers: How to write a function the right way

Just like I mentioned in my first post, PowerShell supports a lot of stuff that makes it pretty easy to dive in and get stuff running. The following two examples are supported in PowerShell, but not something you should really be doing for any reusable tool set. Function MyFunction ($P1, $P2) { Write-host $p1 -foregroundcolor cyan Write-...

PowerShell for Programmers: What happened to my operators?

Operators are one of the most frustrating things about learning PowerShell if you’re coming from just about any other language in existence. Operators like ==, <=, !=. etc. are almost ubiquitous in programming, but none of them are supported in PowerShell. This can lead to some pretty frustrating errors with things like If statements. ...

PowerShell for Programmers: Basic Syntax – Variables, Objects, and Data Types

Variables Variables in PowerShell are going to be a bit different than they are for you in most languages. To start out the conversation, the basic way to create a variable is just by using a “$” and an “=”, but there are cmdlets and other ways to generate them. #easy and best practice way to create most variables $foo = 5 $...

PowerShell for Programmers: A Quick Start Guide

Now that my content has been migrated to the scripting blog, this will be the landing page for the series and I'll be trying to update all the links.  Learning PowerShell can be very useful for people with programming experience. Whether you’re currently a developer, dev-ops, or an admin you can get some serious use out of being familiar...

PowerShell For Programmers: Basic Syntax — CMDLETs

PowerShell might look really strange to you. Many people assume PowerShell is basically CMD-prompt 2.0 because of the way it looks, but it really is a fully operational scripting language underneath. PowerShell has something called a cmdlet (command-let), which for the most part is the same idea as functions you're used to from other ...