Returning a collection of objects from a PowerShell function

If you’re writing a function that returns a collection then don’t forget to include the comma operator in the return statement. If you forget it your function will work correctly when the collection contains multiple objects, but fails when it contains 1 object. Take the following buggy example: If you execute this code when $myarray […]

Read more
Starting a process in PowerShell with dynamic command-line parameters

Starting a command-line process from PowerShell is very easy. A simple java -jar helloworld.jar works just fine. However when I’m starting nodes in my Selenium Grid I need to dynamically create a different number of parameters. The following code will fail because the various strings wont be correctly mapped to the usual argv[] input parameters […]

Read more
Backing up Azure VMs with PowerShell

When experimenting in my lab environment I want to create a backup of the virtual machines. The following PowerShell script will do just that. I assume you’ve already setup your PowerShell to work with azure by doing the following: Setup the Azure PowerShell cmdlets (see: http://azure.microsoft.com/en-us/downloads/) imported your Publish Settings File (see Get-AzurePublishSettingsFile and Import-AzurePublishSettingsFile) […]

Read more
Your new SharePoint site isn’t accesible from the server, but it works from other machines.

You’ve just installed and configured a SharePoint server and you fire-up IE on the server to see if everything works…..Oops, IE keeps asking for your credentials and eventually returns a HTTP 401. Then you notice that the sites are accessible from other machines. In this case you’re running into a security measure called the loopback […]

Read more
grepping in Powershell

Many unix/linux users are intimately familiar with regular expressions and using them with grep, sed or awk in a pipeline. A typical usage scenario is the following command: So how do we do grep in PowerShell? Well, we can use PowerShell’s operators: Operator Description -match Matches its input property agains a regular expression. By default […]

Read more
PowerShell for monitoring proces memory usage

Here is a small bit of PowerShell that monitors the memory usage of a process and outputs the results in a CSV format in the locale of your choosing. I needed this because the sysadmins disabled perfmon and I really wanted to import the raw data into Excel to produce some graphs. You can use […]

Read more
Techdays 2014 – Desired State Configuration (DSC) with PowerShell
Logo of Techdays 2014

Presented by Jeff Wouters at Techdays 2014. Using PowerShell we can define what configuration we want and the DSC framework will make sure that this configuration is enforced on a multitude of machines. Very much like Chef and Puppet. Some examples of configuration settings you can define are Installing windows features, MSI’s, registry settings, services […]

Read more