RSS

Monthly Archives: January 2014

ConfigMgr 2012 SP1/R2: Clear Required PXE Deployment for multiple collections…

A new year, new challenges and new stuff to find out. In my previous blog I stated I wanted to focus more on automating automation, and PowerShell provides great ways of achieving this. I’m still relatively new to PowerShell but I start to love it more and more…

One of my customers asked me to create a workflow to schedule OSD deployments at given times using Wake on LAN. Since they don’t want to deploy all devices at the same time, they want to use different groups of machines (for example, each floor). To achieve this, a number of collections are created, a single Task Sequence is deployed to these collections.

To make sure these devices can be deployed again, we need to use the Clear Required PXE Deployment action at each collection. I can imagine you don’t want to do this every time, especially when a large number of collections are used.

Fortunately, this can be automated using PowerShell.

Basically, a number of collections are used. Each collection has an Id, to keep things simple I need to create a one dimensional array of Id’s. For each Id, I want to execute the Clear Required PXE Deployment command (recognize the ‘pseudo-code’ here?).

For the sake of this blog, I’ve decided to statically populate the array used to get things done (with only 2 collections). Of course, many different ways are possible. However, I wasn’t able to use the Get-CMDeviceCollection –CollectionId cmdlet because it doesn’t provide me an array of Id’s. You might consider using a file as input, as long as the array is populated with valid collection Id’s it will work. Alternatively, you can use Collection Names instead of Id’s but they may not be unique…

So here’s the script with cmdlets that will do the job:

Import-Module <path>\ConfigurationManager.psd1

cd P01:

$collection=”P0100001″,”P0100002″

ForEach ($element in $collection) {Clear-CMPxeDeployment -DeviceCollectionId $element -Force}

In this script, the ConfigMgr Site is P01, you can change this to your own site code (you might want to use variables instead of hard coded values and modify them somewhere else).

During testing I noticed I needed to add the –Force parameter to prevent prompts.

Many ways can be used to have this run automatically, that’s completely up to you.

I have to admit I thought I needed more lines of code. I’m happy to be wrong on that part…

Advertisements
 
 
Steve Thompson [MVP]

The automation specialist

Boudewijn Plomp

Cloud and related stuff...

Anything about IT

by Alex Verboon

MDTGuy.WordPress.com

Deployment Made Simple

Modern Workplace

Azure, Hybrid Identity & Enterprise Mobility + Security

Daan Weda

This WordPress.com site is all about System Center and PowerShell

IT And Management by Abheek

Microsoft certified Trainer -Abheek

Heading To The Clouds

by Marthijn van Rheenen