forked from ConfigMgrHydration/Setup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNew-HYDAutomaticDeploymentRule.ps1
More file actions
121 lines (104 loc) · 3.77 KB
/
New-HYDAutomaticDeploymentRule.ps1
File metadata and controls
121 lines (104 loc) · 3.77 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
120
121
<#
************************************************************************************************************************
Created: 2015-03-01
Version: 1.1
Disclaimer:
This script is provided "AS IS" with no warranties, confers no rights and
is not supported by the authors or DeploymentArtist.
Author - Johan Arwidmark
Twitter: @jarwidmark
Blog : http://deploymentresearch.com
************************************************************************************************************************
#>
Import-Module $env:SMS_ADMIN_UI_PATH.Replace("\bin\i386","\bin\configurationmanager.psd1")
$SiteCode = Get-PSDrive -PSProvider CMSITE
Set-Location "$($SiteCode.Name):\"
$Collection = "SUM Workstations Pilot"
$ADRName = "Client Updates 2015"
$SiteServer = $Env:COMPUTERNAME
$SiteServerFQDN = "$SiteServer.$Env:USERDNSDOMAIN"
$DeployPackageLocation = "\\$SiteServer\Sources\Software Updates\$ADRName"
$Products = "Windows 7","Office 2010"
$UpdateClassifications = "Critical Updates","Security Updates","Service Packs","Update Rollups","Updates"
$Severity = "Critical","Important","Moderate"
if (Get-CMDeviceCollection -Name $Collection)
{
# All good
Write-Output "$Collection collection found, continue"
}
Else
{
Write-Warning "Oupps, $Collection collection does not exist"
Break
}
# Create Software Update Deployment Package
if (Get-CMSoftwareUpdateDeploymentPackage -Name $ADRName)
{
# All good
Write-Output "$ADRName Software Update Deployment Package found, continue"
}
Else
{
Write-Warning "Oupps, $ADRName Software Update Deployment Package does not exist, create it"
$NewDeploymentPackage = New-CMSoftwareUpdateDeploymentPackage -Name $ADRName -Path $DeployPackageLocation
}
# Distribute the Software Update Deployment Package
Start-CMContentDistribution -DeploymentPackageId $NewDeploymentPackage.PackageID -DistributionPointName $SiteServerFQDN
if (Get-CMSoftwareUpdateAutoDeploymentRule -Name $ADRName)
{
# All good
Write-Output "$ADRName Automatic Deployment Rule already exist, abort"
}
Else
{
Write-Output "$ADRName Automatic Deployment Rule does not exist, create it"
$Schedule = New-CMSchedule -DayOfWeek Monday -WeekOrder Third -Start ([Datetime]"08:00")
New-CMSoftwareUpdateAutoDeploymentRule `
-CollectionName $Collection `
-DeploymentPackageName $ADRName `
-Name $ADRName `
-AddToExistingSoftwareUpdateGroup $False `
-AlertTime 4 `
-AlertTimeUnit Weeks `
-AllowRestart $True `
-AllowSoftwareInstallationOutsideMaintenanceWindow $True `
-AllowUseMeteredNetwork $True `
-AvailableImmediately $False `
-AvailableTime 7 `
-AvailableTimeUnit Days `
-BulletinId "MS" `
-DateReleasedOrRevised Last1month `
-DeadlineImmediately $True `
-DeployWithoutLicense $True `
-DisableOperationManager $True `
-DownloadFromInternet $True `
-DownloadFromMicrosoftUpdate $True `
-EnabledAfterCreate $True `
-GenerateOperationManagerAlert $True `
-GenerateSuccessAlert $True `
-Language "English" `
-LanguageSelection "English" `
-NoInstallOnRemote $False `
-NoInstallOnUnprotected $True `
-Product $Products `
-RunType RunTheRuleOnSchedule `
-Schedule $Schedule `
-SendWakeUpPacket $False `
-Severity $Severity `
-SuccessPercent 99 `
-Superseded $False `
-SuppressRestartServer $True `
-SuppressRestartWorkstation $False `
-UpdateClassification $UpdateClassifications `
-UseBranchCache $False `
-UserNotification DisplayAll `
-UseUtc $True `
-VerboseLevel AllMessages `
-WriteFilterHandling $True `
}
#-DeadlineTime $True `
#-DeadlineTimeUnit Hours `
#-MicrosoftAsVendor $True `
#-CustomSeverity "Critical","Important","Moderate" `
#-ArticleId "MS" `
#-Location $DeployPackageLocation `