Close Menu
    Facebook X (Twitter) Instagram
    Sunday, October 12
    X (Twitter) LinkedIn Reddit RSS
    All about Endpoint Management
    • Home
    All about Endpoint Management
    Home»configmgr»Powershell script to export all task sequences in configuration manager without content

    Powershell script to export all task sequences in configuration manager without content

    Eswar KonetiBy Eswar KonetiJanuary 24, 3:09 pm2 Mins Read configmgr 6,110 Views
    Share
    Facebook Twitter LinkedIn Reddit

    Here is a simple PowerShell script that helps you to export a list of all task sequences in your configuration manager server to a folder.

    These exported task sequences can be then imported to another environment (Dev to PROD) and get things moving instead of creating them from scratch.

    Exporting the task sequence can be done using GUI or scripting (Powershell).

    image

    Powershell would be nicer to export multiple task sequence’s in an automated schedule.

    we can make use of Configuration Manager cmdlets and scripts by using the Configuration Manager console or by using a Windows PowerShell session.

    When you run Configuration Manager cmdlets by using the Configuration Manager console, your session runs in the context of the site.

    we will use built-in PowerShell cmdlet to export the list of all task sequences with its dependencies exclude the content of it to a shared folder.

    Export-CMTaskSequence help to exports a Configuration Manager task sequence.

    With this cmdlet, we will create simple powershell script and export all task sequences.

    we will get list of all task sequences using Get-CMTaskSequence and export it.

    If you want to export the task sequence with content, change -WithContent to true and -WithDependence $true

    Change the folder path where to save the task sequence files in zip format.

    <#
    .DESCRIPTION
    Exports all configuration manager task sequences without content/dependencies.

    Author: Eswar Koneti
    Version: 1.0
    Date: 24/Jan/2020
    #>

    #Get the script start time
    $starttime=get-date
    Write-host "Script started at $starttime"
    #import configuration manager powershell module
    try {
    Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)
    }
    catch [System.Exception] {
    Write-Warning "Unable to load the Configuration Manager Powershell module from $env:SMS_ADMIN_UI_PATH" ; break
    }
    #get the sitecode
    $SiteCode = Get-PSDrive -PSProvider CMSITE
    Set-Location -Path "$($SiteCode.Name):\"
    #get list of all task sequences
    $ts = Get-CMTaskSequence  | select Name
    foreach($name in $ts)
    {
    #Replace any unsupported characters with empty space for folder name
    $tsname=$name.Name.replace(":","").replace(",","").replace("*","").replace("?","").replace("\","").replace("\","").replace("<","").replace(">","")
    #export the task sequences to share folder
    Export-CMTaskSequence -Name $name.name -WithDependence $false  -withContent $false -ExportFilePath ("\\servername\Task sequence\"+$tsname+ ".zip") -Force
    }
    #Get script end time
    $endtime=Get-date
    #Get the script execution time (total)
    $Scripttime=($endtime-$starttime).Seconds
    write-host "Script ended at $endtime with execution time of $Scripttime seconds"

    if you want to export specific task sequence, please refer https://docs.microsoft.com/en-us/powershell/module/configurationmanager/export-cmtasksequence?view=sccm-ps

    Recommend reading :

    Get started with Configuration Manager cmdlets https://docs.microsoft.com/en-us/powershell/sccm/overview?view=sccm-ps

    configuration Manager Current branch export task sequences Powershell SCCM sccm cmdlets
    Share. Twitter LinkedIn Email Facebook Reddit

    Related Posts

    Export Microsoft Entra ID User Authentication Methods to CSV using PowerShell & Microsoft Graph API

    August 13, 2:08 pm

    SCCM SQL Report – Compare Installed Apps on TWO Different Computers

    July 13, 10:35 am

    Exporting Intune Win32 Apps with All Properties Using PowerShell and Microsoft Graph

    June 30, 7:01 pm

    5 Comments

    1. keerthana on May 30, 2022 7:20 PM

      THanks, this worked however How to we import this in case of recovery?Do we hav any script ?

      Reply
      • Eswar Koneti on July 7, 2022 11:38 PM

        you can try this powershell cmdlet within configuration manager:

        Import-CMTaskSequence -ImportFilePath "\\Server1\TS\TaskSequence.zip"

        Thanks,
        Eswar

        Reply
    2. keerthana on May 30, 2022 7:19 PM

      How to we import this in case of recovery?Do we hav any script ?

      Reply
      • Eswar Koneti on July 7, 2022 11:38 PM

        you can try this powershell cmdlet within configuration manager:

        Import-CMTaskSequence -ImportFilePath "\\Server1\TS\TaskSequence.zip"

        Thanks,
        Eswar

        Reply
    3. Alex on January 24, 2020 4:00 PM

      This looks great, thanks for sharing!

      Reply

    Leave a ReplyCancel reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Sign Up

    Get email notifications for new posts.

    Author

    I’m Eswar Koneti ,a tech enthusiast, security advocate, and your guide to Microsoft Intune and Modern Device Management. My goal? To turn complex tech into actionable insights for a streamlined management experience. Let’s navigate this journey together!

    Support

    Awards

    Archives

    © Copyright 2009-2025 Eswar Koneti, All rights reserved.

    Type above and press Enter to search. Press Esc to cancel.