3 min read

ConfigMgr - Generate ALOT of Applications for testing

ConfigMgr - Generate ALOT of Applications for testing
Lots of applications generated!

So, working on my "Delete-RetiredApplications"-tool awoke a new need, i had to have a way to generate applications with deploymenttypes and content, so that i could properly test it's functions with export application and content.
Creating fake applications i ConfigMgr is quite easy, but when you need content etc it gets a bit trickier, so today i started working on a script for this.

First i need a list of application names, i could just add random names into a .CSV etc, but, that's boring to look at in CM and the tool, so how could i find a lot of application names, already printed down? ... And then i remembered! The guys over at PatchMyPC has a list of supported products!

Supported Products: Microsoft SCCM and Intune | Patch My PC
You can find a list of all the supported products we support in our catalog for Microsoft SCCM and Intune. You can always request new applications.

And whats even better, i noticed that at the same page they have a "Download Supported Products List (csv)" AMAZING! I didn't even have to do any Copy+Paste.

So, putting one and one together, i came up with an automation which invokes a webrequest to the .csv from PatchMyPC, downloads it, i then import it to Powershell and let the script go to town!

And BAM 614 new applications, each with a content folder containing an msi, and each of them with a deploymentype!



EndpointManagement/New-MEMCMApplications.ps1 at master · Love-A/EndpointManagement
Endpoint Management stuff galore! Contribute to Love-A/EndpointManagement development by creating an account on GitHub.

Cmdline example

#Generate Applications
New-MEMCMApplications -ProviderMachineName "cm01.corp.viamonstra.com" -SiteCode "ps1" -AppListCSVDownloadLocation "https://patchmypc.com/scupcatalog/downloads/PatchMyPC-SupportedProductsList.csv" -AppListCSVDownloadPath "$env:TEMP" -AppListCSVName "Applist.csv" -AppSourceLoction "\\cm01.corp.viamonstra.com\source\Apps" -RetireApps $True


Function New-MEMCMApplications{
    [cmdletbinding(SupportsShouldProcess = $True)]
        [Parameter(Mandatory=$false, HelpMessage="Set if you want the applications to be retired after creation, true of false")]

        [Parameter(Mandatory=$false, HelpMessage="Set where a fake source folder will be created, if you want to")]

        <#[Parameter(Mandatory=$false, HelpMessage="How many apps do you want to create? If left empty, all from list will be created")]
        [Parameter(Mandatory=$true, HelpMessage="URL to the csv with products you want to download")]

        [Parameter(Mandatory=$true, HelpMessage="Rename the downloaded CSV")]

        [Parameter(Mandatory=$true, HelpMessage="Where do you want Applicationlist CSV saved?")]

        [Parameter(Mandatory = $true, HelpMessage="Enter your siteserver FQDN, eg. 'cm01.corp.viamonstra.com'")]
        [Parameter(Mandatory = $true, HelpMessage="Enter your sitecode, eg. ps1")]

            if ((Get-Module ConfigurationManager) -eq $null) {
                Try {
                    Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1"
                Catch {
                    $msgBoxInput = [System.Windows.MessageBox]::Show("ERROR: ConfigMgr PS module could not be loaded", 'ConfigMgr PS module', 'OK')
            if ((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
                New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName
            Set-Location "$($SiteCode):\"

        # Download Productlist and Import CSV
        Invoke-WebRequest -Uri $AppListCSVDownloadLocation -OutFile "$AppListCSVDownloadPath\$AppListCSVName"
        $Applications = Import-CSV "$AppListCSVDownloadPath\$AppListCSVName" -Header "Product" | Select-Object -Skip 2

        # Create CM Application
        Foreach($Application in $Applications){
            New-CMApplication -Name $Application.Product -LocalizedApplicationName $Application.Product

        # Create Contentlocation and add DeploymentType
            Foreach($Application in $Applications){
                Set-Location "$env:SystemDrive"
                New-Item -ItemType Directory -Name $Application.Product -Path "$AppSourceLoction" -Force
                New-Item -ItemType File -Name "$($Application.Product).msi" -Path "$AppSourceLoction\$($Application.Product)\" -Force
                Set-Location "$($SiteCode):\"
                Add-CMScriptDeploymentType -ApplicationName $Application.Product -DeploymentTypeName "Install - $($Application.Product)" -InstallCommand "`"$($Application.Product).msi`" /QN" -ScriptLanguage "PowerShell" -ContentLocation ("$AppSourceLoction\$($Application.Product)\") -ScriptText "$" -Force

        # Retire Applications if set
                Foreach($Application in $Applications){
                    Suspend-CMApplication -Name $Application.Product