Let’s see how to Create SCCM Application Deployment using PowerShell. The PowerShell Cmdlets are native PowerShell commands and NOT standalone executables. Cmdlets are executed along with parameters and values to operate once or multiple times.
After you import the SCCM PowerShell Module into the site server, the PowerShell Cmdlets can be used to create an Application and deploy it to a collection and monitor the deployment. Let’s learn how to use PowerShell cmdlets to manage SCCM Application deployment.
In my last post, I posted about the Create SCCM Package Deployment using PowerShell. Today I will show you how to create and deploy the SCCM Application using SCCM PowerShell Cmdlets.
You can use PowerShell cmdlets to automate the package creation and deployment process with Configuration Manager (aka MEMCM), similar to using SCCM Console. This post helps the PowerShell enthusiast to start working on a PowerShell scripting solution for SCCM Application and Package creation process.
In this post, I will create an SCCM Application using Google Chrome Enterprise MSI and deploy it to a device collection without using the SCCM Console. I have downloaded the 64-bit version of Google Chrome Enterprise from Download Chrome Browser for Your Business – Chrome Enterprise and copied it to the shared folder of my SCCM site server.
- SCCM Configuration Manager Application Creation Deployment Installation
- SCCM Application Supported Deployment Types | ConfigMgr | Endpoint Manager
- SCCM Application Deployment Status Using SQL Query Custom Report
Create SCCM Application Using PowerShell Cmdlets
To create SCCM Application Deployment using PowerShell, you need to connect to the SCCM PowerShell drive. First, we have to connect to the SCCM site server via PowerShell.
I have separated each function of the SCCM Application creation process into different sections and separate PowerShell commands for easy understanding. Later, it won’t be difficult to create one PowerShell command to cover end to end processes from package creation to monitoring.
In the SCCM Console, Click on the Drop-Down option on the top left side corner of the console and click on Connect via Windows PowerShell option.
Click on A on the following warning about the untrusted publisher.
Do you want to run software from this untrusted publisher?
File F:\Program Files\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.PowerShell.Types.ps1xml is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers.
[V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is “D”): A
The New-CMApplication cmdlet creates an SCCM Application using PowerShell. A Configuration Manager application defines the metadata about the application.
Important – Make sure you have collected or downloaded the Application files, supported the manufacturer icon file types (JPG, JEPG, ICO, and PNG), and copied them to SCCM shared folder. Once you have your icons ready, you can now add them to your applications in SCCM.
To create an application, type the following PowerShell command and Press Enter.
New-CMApplication -Name "GoogleChromex64" -Description "Chrome Enterprise Browser" -Publisher Google -SoftwareVersion 101.0.4951.54 -IconLocationFile "\\<Name-of-the-SCCM-Server>\Sources\Test\GoogleChrome\Icon.png"
This command creates an SCCM Application named GoogleChromex64 along with the following PowerShell parameters:
- Name: Provide the Name of the Package (For Example, GoogleChromex64 )
- Description: Adds a description to the Application (Chrome Enterprise Browser)
- Publisher: Specifies the Publisher (Google)
- SoftwareVersion: Specifies the version (101.0.4951.54)
- IconLocationFile: Specifies the file for the Package icon. (For Example, <Name-of-the-SCCM-Server>\Sources\Test\GoogleChrome\Icon.png)
The GoogleChromex64 Application now appears in the Applications node of the Configuration Manager console.
Select the Application from the list to validate the information. Right-click on the Application and select Properties. Here you can see the details in the general tab and Software Center tab specified during the Application creation process.
The Google Chrome icon appears in the Software Center tab as mentioned in the command.
The New-CMApplication PowerShell cmdlet only supports JPG, JEPG, ICO, and PNG extensions. I tried with EXE, and it prompted me with the following error. Therefore, I used the Icon.png file.
WARNING: The extension of the icon file is not valid. This cmdlet supports only JPG, JPEG, ICO, and PNG extensions.
Create Deployment Type for SCCM Application using PowerShell
Using the PowerShell command below, let’s follow the steps to create a new MSI deployment type for an existing Application.
The Add-CMMSiDeploymentType cmdlet adds a Windows Installer (MSI) deployment type to an application. Deployment types include the installation files and information required to install software on devices. Depending on the scenario, an application can be associated with one or more deployment types.
Add-CMMSiDeploymentType -ApplicationName "GoogleChromex64" -DeploymentTypeName "DT_Chromex64" -ContentLocation "\\<Name-of-the-SCCM-Server>\Sources\Test\GoogleChrome\googlechromestandaloneenterprise64.msi" -Comment "New Deployment Type"
The above PowerShell command creates an MSI Deployment type named DT_Chromex64 associated with Application GoogleChromex64 along with the following parameters:
- ApplicationName: Provide the Name of the package (For example, GoogleChromex64)
- DeploymentTypeName: Provide the Name of the Deployment Type (For example, DT_Chromex64)
- ContentLocation: Specifies the location of the source files (For example, \\<Name-of-the-SCCM-Server>\Sources\ Test\GoogleChrome\googlechromestandaloneenterprise64.msi)
- Comment: Adds a comment to the Deployment Type (New Deployment Type)
The DT_Chromex64 Deployment type now appears in the Applications node of the Configuration Manager console.
Select the Deployment Type DT_Chromex64 to validate the information. Right-click on the DT_Chromex64 and select Properties. Here you can see the Deployment Type settings in the General, Content, Programs, Detection Method, User Experience, Requirements, Return Codes, Dependencies tab specified during the Application creation process.
In the Content tab, you can verify the content location.
In the Programs tab, you can verify the Installation program and uninstall the program.
In the Detection Method tab, you can verify the Detection method used to detect the presence of the Application on the target machine. The MSI Deployment type automatically extracts and chooses the MSI product code to detect the application.
Similarly, in the User Experience Tab, you can verify the Installation behavior, logon requirement, and Installation program visibility.
Once you validate the information added to the Deployment Type properties, you can close the Applications wizard and proceed next to prepare for distribution and deployment.
Distribute Application Content to Distribution Point using PowerShell
The following steps help you distribute content to distribution points using the PowerShell command.
The Start-CMContentDistribution cmdlet distributes content from the content library on the site server to distribution points. You can also use the cmdlet to distribute content for the SCCM Objects –
- Applications
- Legacy packages
- Software update deployment packages
- Driver packages
- OS images
- OS upgrade packages
- Boot images
- Content referenced by task sequences
Note – The content can be distributed to distribution points, distribution point groups, or collections associated with distribution point groups.
The next step is to distribute the content of the GoogleChromex64 Application to the Distribution Point, Type and Enter the following command:
Start-CMContentDistribution -ApplicationName "GoogleChromex64" -DistributionPointName <Type-Distribution-Point-Name>
The command distributes the GoogleChromex64 Application to a specified Distribution Point along with the following parameters:
- ApplicationName: Provide the Name of the Application
- DistributionPointName: Specifies the Distribution Point where the Package content will be distributed
Once the content is processed to distribute, You can monitor the content status. If it’s showing the yellow color, distribution is in progress.
If the content distribution were successful, it would appear with Green color, as shown in the GoogleChromex64 Application executed by the Start-CMContentDistribution cmdlet.
SCCM Application Deployment using PowerShell
The New-CMApplicationDeployment cmdlet deploys the application to resources in a collection. The collection parameter of the PowerShell command can be specified by the collection by ID or name.
Type the following command and press Enter to deploy the GoogleChromex64 Application to a collection.
New-CMApplicationDeployment -ApplicationName "GoogleChromex64" -CollectionName "Test_Collection" -DeployAction Install -DeadlineDateTime (get-date) -DeployPurpose Required -UserNotification DisplayAll
The command distributes the GoogleChromex64 Application to a specified Distribution Point along with the following parameters:
- ApplicationName: Provide the Name of the Application (GoogleChromex64)
- CollectionName: Specifies the Collection Name where the Application will be deployed (Test_Collection)
- DeployAction: Specifies the deployment action (Install)
- DeadlineDateTime: Specifies a DateTime object for when this deployment is assigned, also known as the deadline. To get this object, the Get-Date built-in cmdlet is used. (The
Get-Date
cmdlet gets a DateTime object that represents the current date or a date that you specify) - DeployPurpose: Specifies the Deployment Purpose. (Required)
- UserNotification: Specifies the type of user notification (DisplayAll)
Initiate Machine Policy Request & Evaluation Cycle using PowerShell
Here’s how on the client computer, Initiate the Machine Policy Request & Evaluation Cycle to speed up the inventory using PowerShell, SCCM client action Machine Policy Request & Evaluation Cycle “immediately” trigger the re-evaluation of the machine policy process from Windows 10 client.
The Invoke-CMClientAction cmdlet sends a notification to client computers to trigger an immediate client action. The notification can be sent to one or multiple client computers or all the computers in a specified device collection.
To trigger the machine Policy Retrieval and Evaluation cycle on the client machine, type command and press Enter:
Invoke-CMClientNotification -DeviceName TEST_Machine -ActionType ClientNotificationRequestMachinePolicyNow
This command triggers Machine Policy Cycle on the target machine along with the following parameters:
- DeviceName: Provide the Name of the Client machine
- ActionType: Triggers the Machine Policy Retrieval and Evaluation cycle on the client machine (ClientNotificationRequestMachinePolicyNow)
Monitor SCCM Application Deployment Status using PowerShell
The Get-CMApplicationDeploymentStatus cmdlet gets the status of SCCM Application Deployment Status.
Get-CMApplicationDeployment cmdlet gets an object for application deployment. This object is used to configure or remove the deployment.
Let’s Monitor SCCM Application Deployment Status using PowerShell. Now, to check the status of the GoogleChromex64 Application deployment, type the PS command:
$a=Get-CMApplicationDeployment -Name 'GoogleChromex64'
Get-CMApplicationDeploymentStatus -InputObject $a
This command gets the status of the Application named GoogleChromex64 that is deployed to SCCM clients
We can verify the enforcement state for the GoogleChromex64, Deployment Type DT_Chromex64. EnforcementState 1000 means Installation is Successful on the Target collection.
Importance of Get-CMApplicationDeploymentStatus Cmdlet: It provides all the details ( AppName, AssignmentID, AssignmentUniqueID, CollectioID, CollectionName, DTName, EnforcementState etc.) which you will need later to manage, modify, remove the Deployment, Application, DeploymentType)
List of Useful PowerShell Commands to Manage SCCM Application Deployment
Let’s check the List of Useful PowerShell Commands to Manage SCCM Application Deployment. The following is the PS command to remove an SCCM Application deployment.
Remove-CMApplicationDeployment -Name 'GoogleChromex64' -CollectionName "Test_Collection" -Force
PS Command to rename the SCCM Application and Software version details.
$app=Get-CMApplication -Name 'GoogleChromex64'
Set-CMApplication -InputObject $app -NewName GoogleChromex64_Latest -Description 'Google Chrome updated' -SoftwareVersion 101.0.4951.64
PS Command to set the Distribution Priority to High.
$app=Get-CMApplication -Name 'GoogleChromex64'
Set-CMApplication -InputObject $app -DistributionPriority High
PS Command to modify a Windows Installer deployment type
Set-CMMSiDeploymentType -ApplicationName 'GoogleChromex64_Latest' -DeploymentTypeName 'DT_Chromex64' -NewName "DT_Chromex64_Latest" -AddLanguage "en-US","zh-CN" -Comment "New Deployment Type-updated" -EstimatedRuntimeMins 14 -LogonRequirementType OnlyWhenNoUserLoggedOn
PS Command to remove Deployment Type from the SCCM Application.
Remove-CMDeploymentType -ApplicationName 'GoogleChromex64_Latest' -DeploymentTypeName 'DT_Chromex64_Latest' -force
PS command to remove an application from SCCM
Get-CMApplication -Name 'GoogleChromex64_Latest' | Remove-CMApplication -Force
Author
I have been working in IT Infrastructure implementation, deployment, and Maintenance for more than 6 years. I am good at using Enterprise tools – ConfigMgr | Microsoft Endpoint Configuration Manager (MECM) | SCCM, Operating System Deployment (OSD) -Microsoft Deployment Toolkit (MDT) – Standalone, MDT integration with SCCM, Patch Management using WSUS & SCCM. I am improving my skillsets in Mobile Device Management (Microsoft Intune) and Autopilot, and Cloud-based deployment solutions. Recently I have started working on the latest product called Tanium. It’s a product deployment Management & provisioning tool for Windows & Linux.
FYI:
The maximum size of an icon is 250px X 250px
New-CMApplication : Validation of input parameters failed. Cannot continue.