-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCreate_SCCMApplication_1.0.1.ps1
More file actions
119 lines (97 loc) · 5.89 KB
/
Create_SCCMApplication_1.0.1.ps1
File metadata and controls
119 lines (97 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
###################################################################################################################
# Name: Create_SCCMApplication_1.0.1.ps1
# Author: Thomas Marcussen, Thomas@ThomasMarcussen.com
# Date: December,2020
###################################################################################################################
<#
### Notes:
RebootBehavior set to NoAction, Accepted values: BasedOnExitCode, NoAction, ForceReboot, ProgramReboot
AutoInstall $true - indicates whether a task sequence action can install the application
Added Action to Distribute the Content to the DP Group at the end
### Checklist:
- Application Name
- With a deployment type: Same application name
- Content Location
- Installation Program
- Uninstall program
- Repair Program
- Detection method (a specific MSI Product code) - SHOULD BE SET AUTOMATICALLY BY CMDLET
- User expierence: Install for system if resource is device; otherwise install for user
- Logon requirement: weather or not a user is logged on
#>
###################################################################################################################
### Load potentially required SCCM libraries
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.ApplicationManagement.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.ApplicationManagement.MsiInstaller.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.ManagementProvider.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\Microsoft.ConfigurationManagement.ApplicationManagement.Extender.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\DcmObjectModel.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\AdminUI.WqlQueryEngine.dll"
Add-Type -Path "C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole\bin\AdminUI.AppManFoundation.dll"
###################################################################################################################
# Define Configuration Manager Properies HERE:
###################################################################################################################
$CMSiteCode = 'PS1'
$DPGroup = "All DPs"
$CMSiteServer = 'SCCM-CM001.ThomasMarcussen.com'
$CMNameSpace = "root\SMS\site_$CMSiteCode"
###################################################################################################################
# Define Application Properies HERE:
###################################################################################################################
$ApplicationName = 'My Application ver 1.0.0'
$ApplicationVersion = '1.0.0'
$ApplicationMsiPath = '\\SCCM-CM001\Sources\Software\MyApplication\1.0.0\x64\My_Application_1.0.0_x64_EN.msi'
$DeploymentName = $ApplicationName
$MsiInstallCommand = 'msiexec /i $MSICode /qn'
$MsiUninstallCommand = 'msiexec /x $MSICode /qn'
$MsiRepairCommand = 'msiexec /fuma $MSICode /qn'
###################################################################################################################
# START
###################################################################################################################
### Create Application
New-CMApplication -Name $ApplicationName -LocalizedApplicationName $ApplicationName -SoftwareVersion $ApplicationVersion -AutoInstall $true
$Application = Get-CMApplication -Name $ApplicationName
### Create Deployment Type
Add-CMMsiDeploymentType -ApplicationName $Application.LocalizedDisplayName `
-DeploymentTypeName $DeploymentName `
-ContentLocation $ApplicationMsiPath `
-InstallationBehaviorType InstallForSystemIfResourceIsDeviceOtherwiseInstallForUser`
-InstallCommand $MsiInstallCommand`
-UninstallCommand $MsiUnInstallCommand`
-RepairCommand $MsiRepairCommand`
-LogonRequirementType WhereOrNotUserLoggedOn`
-RebootBehavior NoAction`
-Force
### Distribute the Content to the DP Group
Start-CMContentDistribution -ApplicationName $ApplicationName -DistributionPointGroupName $DPGroup #-Verbose
###################################################################################################################
# END
###################################################################################################################
###REF:
# cmdlet ref: https://docs.microsoft.com/en-us/powershell/module/configurationmanager/new-cmapplication?view=sccm-ps
# cmdelet ref: https://docs.microsoft.com/en-us/powershell/module/configurationmanager/add-cmdeploymenttype?view=sccm-ps
# https://docs.microsoft.com/en-us/powershell/module/configurationmanager/add-cmmsideploymenttype?view=sccm-ps
### EXCLUDED PART:
<#
Add-CMDeploymentType is deprecated and only there for compatibility reasons. It's not being updated anymore.
Used instead Add-CMMsiDeploymentType cmdlets for the most part have simplified options sets and should be much easier to use and understand.
#>
<#Add-CMDeploymentType -ApplicationName $Application.LocalizedDisplayName `
-AutoIdentifyFromInstallationFile `
-ForceForUnknownPublisher $true `
-InstallationFileLocation $ApplicationMsiPath `
-InstallationBehaviorType InstallForSystemIfResourceIsDeviceOtherwiseInstallForUser`
-MsiInstaller `
-DeploymentTypeName $ApplicationName
#>
<#Checklist:
- Application Name
- With a deployment type: Same application name
- Content Location
- Installation Program
- Uninstall program
- Repair Program
- Detection method (a specific MSI Product code) - SHOULD BE SET AUTOMATICALLY BY CMDLET
- User expierence: Install for system if resource is device; otherwise install for user
- Logon requirement: weather or not a user is logged on
#>