SCCM VIDEO: CREATING A DEVICE COLLECTION FROM A LIST OF USERS


Most of the time, requests for deployments come in as vague lists of names or departments, and although SCCM provides some great user-based deployment options, you may not feel fully comfortable targeting users for a required deployment. This means you’ll have to run a report, do some copying and pasting, and maybe manually enter some machines into a device collection.

Well, we’ve put together a little script which will help speed up that process.


Download Script

UserCollectionScript_v2
.zip
Download ZIP • 22.41MB

The script relies on SCCM’s user device affinity information that is automatically collected if enabled in client settings. With this info, we can get device associations for users and then use those associations to create device collections for targeting deployments.


Step 1 – Pull in your list of users

We have three different options for inputting our list of users.

  1. Text List

  2. AD User Group

  3. SCCM User Collection

The Text List should be a list of SamAccount Names as we’re going to query SCCM directly with this list. You can use any combination of the three, and the script will take it into account.


Step 2 – Create a targeting collection, or not

First, we check if the collection exists already. If it does not, we check to see if the -LimitingCollection parameter is used. If it is, we’ll create a new Collection, if not, we’ll exit out. The limiting collection is a required collection to create any new Collection in SCCM.

This collection limits the scope of What your new collection can contain. The largest limiting collection is “All Systems.”


Step 3 – Find all the devices associated with each user

We’re going to loop through our list of users, and with each one, run a WMI query to find all associated Devices. Then each of those devices will be added to an array and to the Targeting collection selected above.


Step 4 – Create a simple CSV report (optional)


If you used the -CSVPath parameter, the script will generate a report a .CSV file in the location you designated.


Each row will show what devices were associated with each User and whether or not the devices was successfully added.


There are many reasons a device would not be added, we recommend generating the report and double checking to make sure everything looks right before targeting the collection with a deployment.


Hopefully this makes your deployments a little easier.

In this video, we demonstrate a script that allows an SCCM administrator to create a “Device Collection” using a list of users from a text file as input. The script also supports active directory groups or a user collection.


This PowerShell script uses the “User Device Affinity” feature in SCCM to determine which device belongs to which user.


Download Script

UserCollectionScript_v2
.zip
Download ZIP • 22.41MB

Tags:

  • Facebook
  • Twitter
  • LinkedIn
  • YouTube