SCCM Powershell Scripts for Tasks Automation (2024)

Over the years, we developed many Powershell scripts to make the life of an SCCM administrator easier. Automation with SCCM PowerShell scripts significantly reduces the time and resources required to perform routine tasks. Among these scripts, we automate collection creations on many features, collection membership, deployment management, and report management. Each of our SCCM Powershell scripts is built to run in your environment. You just need to download them and run it. This blog post aims to present all our SCCM PowerShell scripts simply for you to see if any scripts may help you. So here are all these scripts with their descriptions.

Set of Operational SCCM Collections

This script will create a set of 148 SCCM collections for your various needs. These collections can be used for operational tasks afterward. This script has been downloaded more than 75 000 times making this PowerShell script my most downloaded contribution to the community.

I’ve written a Blog Post with all the details:

If you already run an older version of this script, the script will handle already created collections by removing them and recreating them.

SCCM Powershell Scripts for Tasks Automation (1)

Features :

  • Handle collections that were created by a previous version of the script
  • The collections will be placed in an “Operational” folder
  • The collections are set to 7 days refresh period

Full list :

  • All Clients
  • All Clients Active
  • All Client Inactive
  • All Clients Online
  • All Clients R2 CU0
  • All Clients R2 CU1
  • All Clients R2 CU2
  • All Clients R2 CU3
  • All Clients R2 CU4
  • All Clients R2 CU5
  • All Clients R2 SP1
  • All Clients R2 SP1 CU1
  • All Clients R2 SP1 CU2
  • All Clients R2 CU0
  • All Clients R2 CU1
  • All Clients R2 CU2
  • All Clients R2 CU3
  • All Clients R2 CU4
  • All Clients R2 CU5
  • All Clients R2 SP1
  • All Clients R2 SP1 CU1
  • All Clients R2 SP1 CU2
  • All Clients R2 SP1 CU3
  • All Clients Not Latest
  • All Client 1511
  • All Client 1602
  • All Client 1606
  • All Client 1610
  • All Client 1702
  • All Client 1706
  • All Client 1710
  • All Client 1802
  • All Client 1806
  • All Client 1810
  • All Client 1902
  • All Client 1906
  • All Client 1910
  • All Client 2002
  • All Client 2006
  • All Client 2010
  • All Client 2103
  • All Client 2107
  • All Client 2111
  • All Client 2203
  • All Client 2207
  • All Clients Not Reporting HW Inv since 14 days
  • All Clients Not Reporting SW Inv since 30 days
  • All Clients X86
  • All Clients X64
  • All Laptops
  • All HP Laptops
  • All Lenovo Laptops
  • All Dell Laptops
  • All SCCM Distribution Points
  • All SCCM Site Servers
  • All SCCM Site Systems
  • All Servers
  • All Servers Physical
  • All Servers Virtual
  • All Servers Windows 2003 or 2003 R2
  • All Servers Windows 2008 or 2008 R2
  • All Servers Windows 2012 or 2012 R2
  • All Servers Windows 2016
  • All Servers Windows 2019
  • All Systems Created Since 24h
  • All Systems Disabled
  • All Systems Non Client
  • All Systems Obsolete
  • All Systems with SCCM Console
  • All Workstations
  • All Workstations Windows 7
  • All Workstations Windows 8
  • All Workstations Windows 8.1
  • All Workstations Windows 10
  • All Workstations Windows 11
  • All Workstations Windows XP
  • All Windows Update Agent Version Outdated
  • Mobile Devices – All Android
  • Mobile Devices – All Ipad
  • Mobile Devices – All Iphone
  • Mobile Devices – All Windows Phone 10
  • Mobile Devices – All Windows Phone 8
  • Mobile Devices – All Windows Phone 8.1
  • Mobile Devices – All Microsoft Surface
  • Mobile Devices – All Microsoft Surface 3
  • Mobile Devices – All Microsoft Surface 4
  • Mobile Device – All
  • Workstations | Windows 10 v1507
  • Workstations | Windows 10 v1511
  • Workstations | Windows 10 v1607
  • Workstations | Windows 10 v1703
  • Workstations | Windows 10 v1709
  • Workstations | Windows 10 v1803
  • Workstations | Windows 10 v1809
  • Workstations | Windows 10 v1903
  • Workstations | Windows 10 v1909
  • Workstations | Windows 10 v2004
  • Workstations | Windows 10 v20H2
  • Workstations | Windows 10 v21H1
  • Workstations | Windows 10 v21H2
  • Workstations | Windows 11
  • Workstations | Windows 11 v21H2
  • Workstations | Windows 10 Current Branch (CB)
  • Workstations | Windows 10 Current Branch for Business (CBB)
  • Workstations | Windows 10 Long Term Servicing Branch (LTSB)
  • Workstations | Windows 10 Support State – Current
  • Workstations | Windows 10 Support State – Expired Soon
  • Workstations | Windows 10 Support State – Expired
  • Others | Linux Devices
  • Others | MAC OSX Devices
  • Office 365 Build Version | 1705
  • Office 365 Build Version | 1709
  • Office 365 Build Version | 1802
  • Office 365 Build Version | 1803
  • Office 365 Build Version | 1808
  • Office 365 Build Version | 1902
  • Office 365 Build Version | 1908
  • Office 365 Build Version | 1912
  • Office 365 Build Version | 2001
  • Office 365 Build Version | 2002
  • Office 365 Build Version | 2003
  • Office 365 Build Version | 2004
  • Office 365 Build Version | 2005
  • Office 365 Build Version | 2006
  • Office 365 Build Version | 2007
  • Office 365 Build Version | 2008
  • Office 365 Build Version | 2009
  • Office 365 Build Version | 2010
  • Office 365 Build Version | 2011
  • Office 365 Build Version | 2012
  • Office 365 Build Version | 2101
  • Office 365 Build Version | 2102
  • Office 365 Build Version | 2103
  • Office 365 Build Version | 2104
  • Office 365 Build Version | 2105
  • Office 365 Build Version | 2106
  • Office 365 Build Version | 2107
  • Office 365 Build Version | 2108
  • Office 365 Build Version | 2109
  • Office 365 Build Version | 2110
  • Office 365 Channel | Monthly
  • Office 365 Channel | Monthly (Targeted)
  • Office 365 Channel | Semi-Annual
  • Office 365 Channel | Semi-Annual (Targeted)
  • All systems having a duplicate device record
  • Workstations | Co-Management Enabled
  • Workstations | Defender ATP Onboarded
  • Workstations | Defender ATP Not Onboarded

Tip: You can comment out any collections that you don’t want using (#) at the beginning of the “New/Add-CMCollection” lines in the “Create Collection” Section.

Author: Benoit Lecours | Download this script

SCCM PowerShell scripts – Copy User/Device Collection Membership

This SCCM PowerShell script will copy the SCCM User/Device Collection Membership to another SCCM User/Device.

This can be useful in a PC replacement scenario or when a new employee comes in and needs to be a member of the same collection as another employee (Ex: software installation assignment)

Before running the script, enter the right Server name, site code, and domain name.

The script will prompt for confirmation before adding the Device/User to each collection.

Author: Benoit Lecours | Download this script

Create collections with folder structure

The script creates 17 folders and 36 collections. For more details, see the blog post.

The collections will be placed under the right folder based on the purpose of the collection The collections are set to 7 days refresh period The overall idea is to keep collections on a per needs basis.

Folder List

SCCM Powershell Scripts for Tasks Automation (2)

Full collections list

  • All Servers
  • All Workstations
  • All Workstations – Admin
  • MC – CS – Workstation Prod
  • MC – CS – Workstation Test
  • MC – CS – Server Prod
  • MC – CS – Server Test
  • MC – EP – Workstation Prod
  • MC – EP – Workstation Test
  • MC – EP – Server Prod
  • MC – EP – Server Test
  • SRV – INV – Physical
  • SRV – INV – Virtual
  • SRV – INV – Windows 2008 and 2008 R2
  • SRV – INV – Windows 2003 and 2003 R2
  • SRV – INV – Windows 2016
  • WKS – INV – Windows 7
  • WKS – INV – Windows 8
  • WKS – INV – Windows 8.1
  • WKS – INV – Windows XP
  • WKS – INV – SCCM Console
  • WKS – INV – Clients Version | 1710
  • WKS – INV – Laptops | Dell
  • WKS – INV – Laptops | Lenovo
  • WKS – INV – Laptops | HP
  • WKS – INV – Microsoft Surface 4
  • WKS – INV – Windows 10
  • WKS – OSD – Windows 10 – PROD
  • WKS – OSD – Windows 10 – TEST
  • WKS – SU – Exclusion
  • WKS – SU – Pilote
  • WKS – SU – TEST
  • WKS – SU – PROD
  • WKS – SD – Office 365 – PROD
  • WKS – SD – Office 365 – TEST

Note: The script will show an error if the collection already exists, but will continue.

Tip: You can comment out any collections that you don’t want using (#) at the beginning of the “New/Add-CMCollection” lines in the “Create Collection” Section.

For more details on this script, see the

Author: Jonathan Lefebvre | Download this script

Create SCCM Collections based on Active Directory OU

List all Organisational Units (OU) Prompt the Administrator to select the topmost OU where they want to start creating Prompt the Administrator for a folder name The script will create the folder in SCCM The script will create 1 collection per OU from the start OU and will create 1 collection for all OU under the start OU. See the example below if it’s unclear. The script will move the collection to the specified folder

SCCM Powershell Scripts for Tasks Automation (3)

Author: Benoit Lecours | Full blog post | Download this script

Create SCCM collections based on Boundary groups

This PowerShell script automatically creates collections based on all the available boundary groups.

Author: Jonathan Lefebvre | Download this script

Delete old SCCM Deployments

This PowerShell script deletes old SCCM Deployments.

The script will prompt the user to enter the desired date and the script will list all deployments older than the specified date.

The user will be prompted before each deployment deletion before going to the next one.

The script supports the deletion of the following deployment type :

  • Applications
  • Packages
  • Task Sequences
  • Configuration Baseline
  • Software Update

Use this script if you have been using SCCM for a couple of years and have completed / old deployments that are still active.

Author: Benoit Lecours | Download

Delete device collections with no members and no deployments

This SCCM Powershell scripts will detect and delete SCCM Collections that have no members and no deployment assigned to it.

This can be useful for deleting unused/unneeded collections.

The script will detect the targeted collections The script will prompt the user for a confirmation before each deletion The script will not delete collections that have custom security scope

Author: Benoit Lecours | Download

SCCM Report Manager Tool

This Powershell script will let you manage your report on an SCCM Reporting Point. This tool is really useful if you download one of our reports

Based on your SCCM Reporting Point and SCCM site code, the tool allows you to :

  • Upload multiple reports from a specific folder — Useful if you have multiple RDL files to upload at once.
  • Download all reports from a specific SSRS folder — Useful if you have multiple custom reports and are migrating to a new reporting point
  • Change data source of all reports from a specific SSRS folder — Useful if you upload multiple new reports and need to change their data sources

The script needs PowerShell 2.0 and has been tested on SQL 2012 and SQL 2016 Reporting Point.

Author: Benoit Lecours | Download

SCCM Powershell Scripts for Tasks Automation (2024)

FAQs

Can I use PowerShell to automate tasks? ›

The power of PowerShell lies in its versatility in automating a wide range of tasks, from the simple to the complex, making it an indispensable tool for those seeking optimal performance and efficiency.

How do I add a PowerShell script to a task sequence in SCCM? ›

How to Add Run PowerShell Script Step to SCCM Task Sequence
  1. In the Configuration Manager console, go to the Software Library workspace, expand Operating Systems, and then select the Task Sequences node.
  2. In the Task Sequence list, select the task sequence that you want to edit. Select Edit to modify.
Sep 6, 2021

How to run a PowerShell script through SCCM? ›

How to run PowerShell scripts via Scripts in SCCM?
  1. In the SCCM console, click Software Library.
  2. In the Software Library workspace, click Scripts.
  3. On the Home tab, in the Create group, click Create Script.
  4. On the Script page of the Create Script wizard, enter the Script name and PS Script and click Next.
Mar 22, 2023

How do I create a Task Scheduler to run a PowerShell script? ›

To schedule a PowerShell script to run at a specific time, you can configure the task trigger accordingly. In the “Triggers” tab of the task properties, click “New” and select “Daily” or “Weekly” as the trigger type. Set the desired start time and recurrence pattern for when the script should run.

How to automate tasks with shell script? ›

That is also the definition of pretty much any computer program.
  1. #!/bin/bash cd ~/dc_sample_data for file in untrimmed_fastq/*.fastq do echo "My file name is $file" done. ...
  2. $ bash myscript.sh My file name is untrimmed_fastq/SRR097977.fastq My file name is untrimmed_fastq/SRR098026.fastq. ...
  3. $ chmod +x myscript.sh.

How to schedule scripts in SCCM? ›

Schedule scripts' runtime
  1. In the Configuration Manager console, click Assets and Compliance.
  2. In the Assets and Compliance workspace, click Device Collections.
  3. In the Device Collections list, click the collection of devices on which you want to schedule the script.
  4. Select a collection of your choice, click Run Script.
Oct 9, 2023

How to run an Exchange PowerShell script as a scheduled task? ›

Schedule PowerShell Exchange script
  1. Type a descriptive name for your task and click Next.
  2. On the Trigger section, choose your schedule that fits your needs.
  3. On the Action, choose “Start a program“, Click Next.
  4. On the “Start a Program” subsection, Enter:

How to automate Windows tasks? ›

How to automate tasks using Task Scheduler
  1. Step 1: Open the Windows Start Menu and search for Task Scheduler, then select on the top result.
  2. Step 2: In the open window, under Actions in the sidebar, choose the Create Basic Task option. ...
  3. Step 3: Select Next and choose when you want the task to run.
Apr 13, 2024

Can power automate run PowerShell scripts? ›

Integrating PowerShell scripts with other applications and services in Power Automate is a great way to enhance workflow automation and streamline processes. To get started, follow these steps: Create a new flow in Power Automate. Add the “Execute a script” action.

Which allows advanced users to create scripts to automate tasks? ›

The UnityVSA user interface that allows advanced users to create scripts for automating routine tasks is the Unisphere CLI (Command Line Interface). The Unisphere CLI provides a text-based interface where users can write, run, and manage custom scripts.

What is the SCCM task sequence? ›

A task sequence is a mechanism used in System Center Configuration Manager for performing multiple steps or tasks on a client computer at the command-line level without requiring user intervention. Task sequences are used by System Center Configuration Manager to deploy operating systems.

How do I connect to SCCM PowerShell? ›

The easiest method to open PowerShell is directly from the Configuration Manager console. Launch the Configuration Manager console. In the upper-left corner, there's a blue rectangle. Select the white arrow in the blue rectangle, and choose Connect via Windows PowerShell.

How do I open Task Manager in PowerShell script? ›

You can likewise use Command Prompt or PowerShell to open Task Manager, both of which are accessible via Terminal. Just type taskmgr.exe, and then press Enter.

Is PowerShell an automation tool? ›

PowerShell is a cross-platform task automation solution made up of a command-line shell, a scripting language, and a configuration management framework. PowerShell runs on Windows, Linux, and macOS.

Can you use PowerShell in power automate? ›

With PowerShell cmdlets for Power Platform creators and administrators, you can automate many monitoring and management tasks. Tasks that are only possible manually today in Power Apps, Power Automate, or the Power Platform activity center.

Can PowerShell automate Excel? ›

In this article, we will learn how to manipulate excel rows and columns to automate a repetitive report generation in ps (PowerShell). Last month I was assigned a project to automate financial monthly summary reports. And that's when I came across ps, which is a great way to automate anything and everything.

Can I automate tasks in Windows? ›

On Windows 10, the Task Scheduler lets you create and run tasks automatically, and in this guide, I'll outline the steps to complete the process. Typically, the operating system and certain apps use the scheduler to automate maintenance tasks (such as disk defragmentation, disk cleanup, and updates).

Top Articles
Latest Posts
Recommended Articles
Article information

Author: Nicola Considine CPA

Last Updated:

Views: 5960

Rating: 4.9 / 5 (69 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Nicola Considine CPA

Birthday: 1993-02-26

Address: 3809 Clinton Inlet, East Aleisha, UT 46318-2392

Phone: +2681424145499

Job: Government Technician

Hobby: Calligraphy, Lego building, Worldbuilding, Shooting, Bird watching, Shopping, Cooking

Introduction: My name is Nicola Considine CPA, I am a determined, witty, powerful, brainy, open, smiling, proud person who loves writing and wants to share my knowledge and understanding with you.