Create 148 Operational SCCM Collections using this Powershell Script

Benoit LecoursPowershell, SCCM28 Comments

Using Powershell you can do many things in SCCM. Over the years, in many SCCM consulting projects we got involved in, we get the same question: “Can you create SCCM collections for Servers, Laptops, Workstations, Windows 10…”. Back in 2015, I started to build an SCCM collection PowerShell script to create SCCM operational collections which we create just after an SCCM installation. With time, I added more and more collections to the script. Fast forward to today, the script now contains 148 collections and has been downloaded more than 75 000 times making this PowerShell script my most downloaded contribution to the community. This set of collections usually covers 95% of the initial client needs. All you need to do is to run the SCCM collection PowerShell script on your SCCM server and wait. In about 5 minutes, you’ll end up having 148 collections in an Operational folder. The collections are set to … Read More

SCCM Remove Computer from Collection after OSD

Benoit LecoursPowershell, SCCM1 Comment

This post is a step-by-step guide on how to remove computers from the collection after OSD. If you’re using specific collections for your OSD deployments you certainly know that the collections are not emptied automatically. After a couple of weeks, you’ll end up with a collection full of systems. The bad news is that there’s nothing built-in in the product, the good news is that our friend PowerShell can do this dirty job. To run the script : The imported module needs to be trusted The script must run in x86 mode The computer account must have proper permission (SCCM and DCOM) SCCM Remove Collection OSD – Permission You need to add your primary site computer account as a “Full Administrator” in SCCM You need to add the “System” account “Remote Access” right in DCOM permission Launch “dcomcnfg.exe” Navigate to Component Services / Computer / My Computers (Right-Click) / Properties … Read More

Getting started with SCCM Powershell cmdlet

Benoit LecoursPowershell, SCCMLeave a Comment

You can run SCCM Powershell cmdlet and scripts from the SCCM console or from a Windows PowerShell session. This is very useful to do stuff in SCCM without using the console. You can do pretty much anything using Powershell. When you get used to it, you can write more complex scripts to automate and save lots of time. Supported versions of SCCM’s current branch support Windows PowerShell version 5.1. Starting in version 2010, the Configuration Manager PowerShell cmdlet library supports PowerShell 7.  If you’re not familiar with PowerShell and SCCM, the easiest way to connect to your site is to use the shortcut in the console : In the SCCM console Select the upper-left white arrow choose Connect via Windows PowerShell A Windows PowerShell loads, you’ll see a prompt that contains your site code. For example, if the site code is “SCD”, the prompt will show: PS SCD:\> SCCM Powershell Cmdlet Syntax … Read More

Send an Email when SCCM OSD Completes a Deployment

Benoit LecoursPowershell, SCCM32 Comments

When deploying an operating system with SCCM / MEMCM, monitoring your deployment is crucial. You can use reports in a more dynamic way. Imagine receiving an email saying “Hey your deployment is complete. The computer can be delivered to the client”. SCCM can send an email based on a specific status message generated by the site server. And this is exactly what will be done in this blog post. SCCM records everything action in Status Messages. You are probably familiar with the tons server logs files but SCCM also records everything on the site server itself. A quick look at the Status message shows that there’s tons of available information. Status Message In the SCCM Console Go to Monitoring / System Status / Status Message Queries / All Status Message Status Message shows all actions, there’s lots of valuable information in there Yeah great !… now what? Using the power … Read More

Create SCCM Maintenance Windows using Powershell

Benoit LecoursPowershell, SCCM1 Comment

Maintenance windows are useful to ensure that important tasks on devices are run at the right moment. Usually you create a Maintenance Window in the SCCM console butyou can manage your SCCM maintenance Windows using PowerShell. This is useful when you have to create many. Here’s a simple example but you can get creative. This example will create a Maintenance Window that occurs each fourth day of every 3 months effective the time you create it at 3:00 AM. We are using the New-CMMaintenanceWindow and New-CMSchedule cmdlet. You have to know that Maintenance windows can be applied to Application and package, Software update, Compliance settings and task sequences. The maximum duration of a window is 24h. SCCM Maintenance Windows Powershell Validation Once you’ve run the script and the Maintenance Windows is created, you can check in the SCCM console or use one of our report. Console In the SCCM Console … Read More

SCCM Powershell collection boundary groups

Jonathan LefebvrePowershell, SCCM2 Comments

With SCCM 2002 that was just released, a small but extremely useful feature is now available in console. It is now possible to view what boundary group a device is connected to! This offers a new opportunity with collections based on Boundary groups, which could mean physical sites or any other meaningful needs in your environment. I’ve created a PowerShell script that automatically creates collections based on all the available boundary groups. Requirements SCCM must be at least version 2002. See our Step-by-step guide upgrade guide here SCCM Powershell collection boundary groups The script can be downloaded on GitHub, since Technet Gallery is retiring soon. Be sure to rate the submission if you are using it. Example of the result of the script Collection query for boundary groups Thanks to fellow SystemCenterDudes, Eswar Koneti, for his post about that exact query This isn’t the typical query for collections Note that … Read More

Use Powershell to generate certificates for your lab

Thomas LarsenPowershell, SCCM1 Comment

Certificates are becoming more and more important and are used almost everywhere and many solutions need a certificate to even start up. In production, you should have a healthy PKI solution up and running, but in your lab environment or if you just want to quickly test things without involving your company’s PKI-guy you can use PowerShell to quickly spin up certificates. Here’s how to use Powershell to generate certificates in your lab : Create a Root CA First we’ll create our root certificate. Copy the Thumbprint of your newly generated root cert into notepad ,you’ll need it later. This does a few things. It creates a new certificate with the CertSign usage with means we can use it to sign other certificate and puts it in the current users cert store. This is our new mini root certificate that we’ll use to sign all the other certificates. The second … Read More

SCCM Powershell Script to create Collections Folders

Jonathan LefebvrePowershell, SCCM2 Comments

Following the excellent PowerShell script that Benoit wrote to create operational collection, I decided to rethink it a bit to help classify collections and ease Role-based administration control implementation when a different group of users accesses SCCM. On top of that, the way folders for collections are designed, it helps implement a naming convention to keep things clear all across the SCCM console. This script works with any SCCM version. The overall idea is to keep collections on a per needs basis. Having a collection that receives client settings, 1-2 applications, OSD and Windows Updates can lead to unplanned/accidental deployment or misconfiguration. With one collection per need, everything is well targeted. I also prefer to have collection for inventory to feed my deployment collections, instead of always recreating the queries. I’ve been using the same methodology for years at multiple clients site. When I go back after a few years, … Read More

How to install and configure SCCM Cmdlet Library

Benoit LecoursPowershell, SCCM2 Comments

Today, Microsoft has release the SCCM Cmdlet Library. The SCCM product group is taking a new update direction: from now on, the future Cumulative Updates (CU) releases won’t contain any PowerShell changes. The SCCM Cmdlet Library will be the vehicle for any future cmdlet updates. This separation means no more breaking cmdlets when updating to a new CU and more frequent cmdlets fixes/releases from Microsoft. Better of both world ! What’s even better is that it checks and notifies you automatically for library updates on a daily basis. Requirements SCCM 20012 R2 is supported (any CU) SCCM 2012 SP1 is not supported Read the release notes carefully as it describes known issues, breaking changes, and other important details about this initial release. How to install SCCM Cmdlet Library The SCCM Cmdlet Library must be installed on each workstation computers that runs the SCCM Console and needs PowerShell access. Download ConfigMgr2012PowerShellCmdlets.msi from Microsoft Download Center On the Welcome screen, click Next Click … Read More

New-CMDeviceCollectionVariable creating only 1 variable

Benoit LecoursPowershell, SCCMLeave a Comment

Update 2014-12-04 : Microsoft will have a fix in the next release of the PowerShell cmdlets. (Not released yet) I recently had a problem with the PowerShell command New-CMDeviceCollectionVariable creating only 1 variable. I had to create a set of collection with variables in an OSD project. The goal was to create 20 collections with 7 different variables. Nothing too complicated, Powershell to the rescue ! So I start creating my script, everything went smoothly, no errors were returned. After verification on the created collection I found out that only 1 variable per collection were created instead of the 7 intended. I decided to do a simple test to verify that New-CMDeviceCollectionVariable cmdlet was working correctly. I had problem in the past with another cmdlet and since then I like to double check if they work correctly. Create a Test collection Collection Test gets created Create a new variable with a value assigned to the Test … Read More