Forums on Intune, SCCM, and Windows 11

Welcome to the forums. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your topics and posts, as well as connect with other members through your own private inbox!

SOLVED Application Creation/distribution/Collection creation and deployment using PS

  • Thread starter Thread starter Gokul
  • Start date Start date
  • Replies Replies 1
  • Views Views 4K
Status
Not open for further replies.

Gokul

Well-Known Member
Staff member
Messages
321
Solutions
4
Reaction score
58
Points
28
GOOD DAY ALL

We have Created PS script which enables us to do below in one shot
Note: we have commented in the script to edit as per your infra and some part do not do any changes .And Save the Script in .ps format .
1.Creation of application
You can create the application using script , just need to provide the application details

2.Collection creation
Collection can be created and placed in desired folder
3.Content distribution
Content can distributed to multiple DPs
4.App Deployment
using this PS we can deploy the app to the collection which we are created
 
# Script Created by Gokul
#Version 2.0
#Modified script to import values from csv file
#Modified script to move Application to Vendor folder 20-FEB-2020

# Site configuration - Connecting to Primary Site
$SiteCode = "P01" # Site code
$ProviderMachineName = "xyz.com" # SMS Provider machine name

# Customizations
$initParams = @{}

#$initParams.Add("Verbose", $true) # Uncomment this line to enable verbose logging
#$initParams.Add("ErrorAction", "Stop") # Uncomment this line to stop the script on any errors

# Do not change anything below this line

# Import the ConfigurationManager.psd1 module
if((Get-Module ConfigurationManager) -eq $null) {
Import-Module "$($ENV:SMS_ADMIN_UI_PATH)\..\ConfigurationManager.psd1" @initParams
}

# Connect to the site's drive if it is not already present
if((Get-PSDrive -Name $SiteCode -PSProvider CMSite -ErrorAction SilentlyContinue) -eq $null) {
New-PSDrive -Name $SiteCode -PSProvider CMSite -Root $ProviderMachineName @initParams
}

# Set the current location to be the site code.
Set-Location "$($SiteCode):\" @initParams
#Defining SCCM Variables

# ******************************Comments "Please enter your inputs here"****************************
$scriptdir = "C:\scripts\Gokul_Scripts\Create_New_Application"#PS direction
$ImportCsv = Import-Csv $scriptdir\"Create_Application.csv"
foreach ($AppCreate in $ImportCsv)
{

$Application = $AppCreate.CMApplicationName #Application Name
$Version = $AppCreate.CMApplicationVersion #Application Version
$Publisher = $AppCreate.Publisher #Publisher Name
$Description = $AppCreate.Description #Description
$Location = $AppCreate.Location #Content Location
$Collection = $AppCreate.Collection #Collection Name
$DP1 = $AppCreate.DP1 #Name of the DP the content should be distributed to
$DP2 = $AppCreate.DP2 #Name of the DP the content should be distributed to
$DP3 = $AppCreate.DP3 #Name of the DP the content should be distributed to
$Install = $AppCreate.InstallCommand #Install command
$Uninstall = $AppCreate.UninstallCommand #Uninstall Command
$VendorFolder = $AppCreate.VendorFolder # Change the Folder name to move the application to its vendor folder in SCCM console
$AppFolderMove = "$($Sitecode):\Application\$VendorFolder"


# ********************* Note : Below script should not be modified**********************************************



# Creating Application

New-CMApplication -Name $Application -SoftwareVersion $Version -Publisher $Publisher -Description $Description -Verbose

#Move the application to its respective folder after the script is run.

#Add Deployment Type


Add-CMMsiDeploymentType -ApplicationName $Application -ContentLocation $Location -InstallationBehaviorType InstallForSystem -DeploymentTypeName $Application -InstallCommand $Install -UninstallCommand $Uninstall -Force -Verbose

#Distributing the content

Start-CMContentDistribution -ApplicationName $Application -DistributionPointName $DP1,$DP2,$DP3 -Verbose

#Move Application to Vendor Folder

$MoveApplication = Get-CMApplication -Name $Application
Move-CMObject -InputObject $MoveApplication -FolderPath $AppFolderMove -Verbose

#Create Collection

New-CMDeviceCollection -name $Collection -LimitingCollectionName 'All Systems' -Verbose


$FolderPath = "$($Sitecode):\DeviceCollection\Other Collections for Software deployment\Test - Applications"

$Movecollection = Get-CMCollection -Name $Collection

Move-CMObject -InputObject $Movecollection -FolderPath $FolderPath -Verbose

#Deploy the application to collection

New-CMApplicationDeployment -CollectionName $Collection -Name $Application -DeployAction Install -DeployPurpose Required -UserNotification DisplaySoftwareCenterOnly -AvailableDateTime (Get-Date) -DeadlineDateTime (Get-Date) -TimeBaseOn LocalTime -Verbose

}
 
Status
Not open for further replies.

Forum statistics

Threads
7,178
Messages
28,003
Members
18,307
Latest member
nhamilton

Trending content

Back
Top