Testing for the Presence of a Registry Key and Value

There are a number of different ways to test for the presence of a registry key and value in PowerShell. Here’s how I like to go about it. We’ll use an example key HKLM:\SOFTWARE\TestSoftware with a single value Version: Check for the key You can use the Test-Path cmdlet to check for the key, but not for specific values within a key. For example Test-Path 'HKLM:\\SOFTWARE\\TestSoftware' but not Test-Path 'HKLM:\\SOFTWARE\\TestSoftware\\Version' So for the value we need to work a bit harder.

Reporting On Installed Windows Programs Via The Registry

Quite a common request for working with Windows machines is to report the software installed on them. If you don’t have a centralised system for reporting on client software (many places don’t) then you may turn to some form of scripted method to obtain this information. Most people tend to head to Add / Remove Programs when thinking about what software is installed in Windows. However, not all applications will always populate information in there, depending on how they have been installed.

Adding and Removing Items from a PowerShell Array

Adding and removing Items from a PowerShell array is a topic which can lead to some confusion, so here are a few tips for you. Create an array and we will note the type System.Array: $Fruits = "Apple","Pear","Banana","Orange" $Fruits.GetType() However, if we try to Add or Remove items to the array we get errors that the “Collection was of a fixed size” $Fruits.Add("Kiwi") $Fruits.Remove("Apple") $Fruits.IsFixedSize We can see that the array we originally created is of a fixed size.

Winter Scripting Games 2014

If you’re looking to learn or improve on existing skills as part of a new year goal and one of those in PowerShell, then you may find it useful to check out the Winter Scripting Games 2014. When you are looking to improve your scripting skills it can sometimes be tricky if you don’t have a practical problem to solve. By taking part in these games you will have a number of opportunities to apply your skills to real problems.