SCCM : Refresh Device Collection Memberships

I’m in the finishing stages of a new SCCM deployment, but also in the process of an Active Directory consolidation at the moment, and ran in to the following issue:

A machine from Domain A has been re-imaged using SCCM to run in Domain B.
SCCM has a Device Collection X for Domain A and Device Collection Y for Domain B.
Device Collection Y has a Deployment for a specific VPN Application that’s required, otherwise it won’t run.

The Problem

The engineer that re-images the machine forgot to remove the machine from Domain A and therefor doesn’t get the VPN Application, as the Client is still recognized as being an active machine on Domain A, taking precedent over the fact that it ALSO exists in Domain B now [same MAC address etc].

The Solution

By manually removing [yes, this needs to be automated at a later time as well] the old AD machine from Domain A and refreshing the Device Collection’s memberships, the issue can be resolved.

Normally this is something that gets done on a regular interval [in this case, every 24h], but we need to force it, sometimes for multiple Device Collections.

Instead of using the clunky GUI, PowerShell’s to the rescue 🙂

There is a WMI Method in the SMS_Collection which does exactly what we require: Refresh the Membership of a Collection 🙂

The Code

Here’s the code that does the trick for me

Happy Scripting! 🙂


SCCM: Get-AppUninstallInfo – Easily creating SCCM Applications

New toys!

As mentioned before, I’ve recently started a new assignment, one that required me to design and roll out a System Center Configuration Manager solution for 4 locations.

While that wasn’t too difficult and the configuration was quite straightforward [thanks to my friends at Manning and Google], the biggest challenge came when creating packages to deploy.
Luckily I was quite familiar with packaging and .MSI editing due to various MDT configurations I had made, but the latest “Current Branch” version of SCCM has “Applications”, which are smart packages [pieces of software] which you can deploy, but also uninstall if you want.

Great stuff, exactly what we needed…

The problem

If you don’t have the software in an .MSI format, you will need to manually enter various information in order for it to become “smart”, otherwise the application will only be able to install itself and possibly retry.

What kind of information do we need and where can we find it?

First, we’ll need to install the software we want to package on a dummy/test machine, so we can find certain behaviour of the program, then we need to scour the registry for the following info:

  • The DisplayName
  • The DisplayVersion
  • The UninstallString
  • The Registry Key where this is all located

The Code

Now my solution isn’t “perfect” yet, as currently I KNOW I only have to check x64 machines, but the code can be easily manipulated to do a check on system architecture :

but for now it will do just fine:

Simply start the script, defining the name of the application or part of it and see the magic unfold 🙂



Happy Scripting! 🙂


Script Dumpster: Setting Proxy server settings

OK, so I’m at my new job and for the first time in years, I have to deal with proxy servers again…

Since I’m used to having full admin rights on my machine and unrestricted internet, this was somewhat of a shock, while perfect for my productivity as well 😛

Unfortunately for them, I have since been informed that a special IT proxy is available, which provides this access, hence me being able to update my site again 🙂


Here’s a quick script which allows me to switch from “normal” proxy (while pre-defined you can set it to whatever you prefer) to IT proxy or disable it all together

Happy Scripting! 🙂