-
Notifications
You must be signed in to change notification settings - Fork 38
/
EnableEarlyUpdateRing2002.ps1
102 lines (81 loc) · 3.26 KB
/
EnableEarlyUpdateRing2002.ps1
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
<#
.SYNOPSIS
Enable fast ring for 2002 update package in ConfigMgr Current Branch.
.DESCRIPTION
This script will allow you to enable fast UpdateRing in ConfigMgr Current Branch.
.PARAMETER SiteServer
Top level site server name or IP address.
#>
Param (
[Parameter(Mandatory=$True,Position=0, ParameterSetName="SiteServer Name or IP address", HelpMessage="Top level site server name or IP address.")]
[ValidateNotNullOrEmpty()]
[ValidateScript({Test-Connection -ComputerName $_ -Count 1 -Quiet})]
[string]$siteServer
)
$WmiObjectSiteClass = "SMS_SCI_SiteDefinition"
$WmiObjectClass = "SMS_SCI_Component"
$WmiComponentName = "ComponentName='SMS_DMP_DOWNLOADER'"
$WmiComponentNameUpdateRing = "UpdateRing"
$UpdateRingValue = 200253
# Determine SiteCode from WMI
# Get provider instance
try{
Write-Host -Message "Determine the providers on the siteServer: '$($siteServer)'"
$providerMachine = Get-WmiObject -namespace "root\sms" -class "SMS_ProviderLocation" -computername $siteServer
# Get the first provider if there are multiple
if($providerMachine -is [system.array])
{
$providerMachine=$providerMachine[0]
}
$SiteCode = $providerMachine.SiteCode
$ProviderMachineName = $providerMachine.Machine
$WmiObjectNameSpace="root\SMS\site_$($SiteCode)"
Write-Host -Message "SiteCode: '$($SiteCode)'"
Write-Host -Message "Provider Machine Name: '$($ProviderMachineName)'"
# Get top level site sitecode
$SiteDefinition = Get-WmiObject -Namespace $WmiObjectNameSpace -ComputerName $ProviderMachineName -Class $WmiObjectSiteClass | Where-Object { $_.ParentSiteCode -eq "" }
if(!($SiteCode -eq $SiteDefinition.SiteCode) )
{
Write-Error -Message "Please provide the top level site IP or siteserver name."
return;
}
}
catch [System.UnauthorizedAccessException] {
Write-Warning -Message "Access denied" ; break
}
catch [System.Exception] {
Write-Warning -Message "Unable to determine Site Code" ; break
}
#Get component
$WmiObject = Get-WmiObject -Namespace $WmiObjectNameSpace -ComputerName $ProviderMachineName -Class $WmiObjectClass -Filter $WmiComponentName| Where-Object { $_.SiteCode -eq $SiteCode }
#Get embedded property
$props = $WmiObject.Props
$props = $props | where {$_.PropertyName -eq $WmiComponentNameUpdateRing}
if (!$props) {
#Create embedded property
$EmbeddedProperty = ([WMICLASS]"\\$($ProviderMachineName)\root\SMS\site_$($SiteCode):SMS_EmbeddedProperty").CreateInstance()
$EmbeddedProperty.PropertyName = $WmiComponentNameUpdateRing
$EmbeddedProperty.Value = $UpdateRingValue
$EmbeddedProperty.Value1 = ""
$EmbeddedProperty.Value2 = ""
$WmiObject.Props += [System.Management.ManagementBaseObject] $EmbeddedProperty
$WmiObject.put()
}
else
{
$props = $WmiObject.Props
$index = 0
ForEach($oProp in $props)
{
if($oProp.PropertyName -eq $WmiComponentNameUpdateRing)
{
$oProp.Value=$UpdateRingValue
$props[$index]=$oProp;
}
$index++
}
$WmiObject.Props = $props
$WmiObject.put()
}
Write-Host "The command(s) completed successfully"