ConfigMgr - Generate ALOT of Applications for testing

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!
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!


Download
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
Script
Function New-MEMCMApplications{
[cmdletbinding(SupportsShouldProcess = $True)]
Param(
[Parameter(Mandatory=$false, HelpMessage="Set if you want the applications to be retired after creation, true of false")]
[bool]$RetireApps,
[Parameter(Mandatory=$false, HelpMessage="Set where a fake source folder will be created, if you want to")]
[string]$AppSourceLoction,
<#[Parameter(Mandatory=$false, HelpMessage="How many apps do you want to create? If left empty, all from list will be created")]
[string]$NumberOfApps,#>
[Parameter(Mandatory=$true, HelpMessage="URL to the csv with products you want to download")]
[string]$AppListCSVDownloadLocation,
[Parameter(Mandatory=$true, HelpMessage="Rename the downloaded CSV")]
[string]$AppListCSVName,
[Parameter(Mandatory=$true, HelpMessage="Where do you want Applicationlist CSV saved?")]
[string]$AppListCSVDownloadPath,
[Parameter(Mandatory = $true, HelpMessage="Enter your siteserver FQDN, eg. 'cm01.corp.viamonstra.com'")]
$ProviderMachineName,
[Parameter(Mandatory = $true, HelpMessage="Enter your sitecode, eg. ps1")]
$SiteCode
)
begin{
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
}
Process{
# Create CM Application
Foreach($Application in $Applications){
New-CMApplication -Name $Application.Product -LocalizedApplicationName $Application.Product
}
# Create Contentlocation and add DeploymentType
If(![string]::IsNullOrEmpty($AppSourceLoction)){
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
}
}
}
End{
# Retire Applications if set
switch($RetireApps){
"true"{
Foreach($Application in $Applications){
Suspend-CMApplication -Name $Application.Product
}
}
}
}
}