17
17
. NOTES
18
18
https://docs.microsoft.com/en-us/mem/configmgr/develop/reference/core/clients/client-classes/triggerschedule-method-in-class-sms_client
19
19
https://stackoverflow.com/a/63916401/8315671
20
+ https://www.manishbangia.com/initiate-sccm-client-actions-cmd-line/
20
21
#>
22
+
23
+ # Requires -RunAsAdministrator
24
+
21
25
function Trigger-Schedule
22
26
{
23
27
[CmdletBinding ()]
@@ -45,6 +49,7 @@ function Trigger-Schedule
45
49
$All
46
50
)
47
51
52
+ # https://learn.microsoft.com/en-us/mem/configmgr/develop/reference/core/clients/client-classes/triggerschedule-method-in-class-sms_client#parameters
48
53
$SupportedSchedules = @ {
49
54
" AppDeployment" = " {00000000-0000-0000-0000-000000000121}"
50
55
" DiscoveryData" = " {00000000-0000-0000-0000-000000000003}"
@@ -55,24 +60,24 @@ function Trigger-Schedule
55
60
" SoftwareMeteringUsage" = " {00000000-0000-0000-0000-000000000031}"
56
61
" SoftwareUpdates" = " {00000000-0000-0000-0000-000000000108}"
57
62
" SoftwareUpdatesScan" = " {00000000-0000-0000-0000-000000000113}"
63
+ " PolicyAgentRequestAssignment" = " {00000000-0000-0000-0000-000000000026}"
58
64
" UserPolicyRetrievalEvalCycle" = " {00000000-0000-0000-0000-000000000027}"
59
65
" WindowsInstallerSourceListUpdate" = " {00000000-0000-0000-0000-000000000032}"
60
66
}
61
67
68
+ $SID = (Get-CimInstance - Namespace root\ccm - ClassName CCM_UserLogonEvents | Where-Object - FilterScript {$null -eq $_.LogoffTime }).UserSID.Replace(" -" , " _" )
69
+
62
70
foreach ($Schedule in $Schedules )
63
71
{
64
- if ($Schedule -eq " UserPolicyRetrievalEvalCycle" ) # "Policy Agent Request Assignment" too
65
- {
66
- Write-Verbose - Message $SupportedSchedules [$Schedule ] - Verbose
72
+ Write-Verbose - Message $SupportedSchedules [$Schedule ] - Verbose
67
73
68
- $SID = (Get-CimInstance - Namespace root\ccm - ClassName CCM_UserLogonEvents | Where-Object - FilterScript {$null -eq $_.LogoffTime }).UserSID.Replace(" -" , " _" )
74
+ if (($Schedule -eq " PolicyAgentRequestAssignment" ) -or ($Schedule -eq " UserPolicyRetrieval" ))
75
+ {
69
76
$ActualConfig = Get-WmiObject - ClassName CCM_Scheduler_ScheduledMessage - Namespace root\ccm\Policy\$SID \ActualConfig | Where-Object - FilterScript {$_.ScheduledMessageID -eq $SupportedSchedules [$Schedule ]}
70
77
$ActualConfig.Triggers = @ (' SimpleInterval;Minutes=1;MaxRandomDelayMinutes=0' )
71
78
$ActualConfig.Put ()
72
79
73
- Start-Sleep - Seconds 10
74
-
75
- # $SID = (Get-CimInstance -namespace root\ccm -ClassName CCM_UserLogonEvents | Where-Object -FilterScript {$null -eq $_.LogoffTime}).UserSID.Replace("-", "_")
80
+ # $SID = (Get-CimInstance -Namespace root\ccm -ClassName CCM_UserLogonEvents | Where-Object -FilterScript {$null -eq $_.LogoffTime}).UserSID.Replace("-", "_")
76
81
# $ActualConfig = Get-CimInstance -Namespace root\ccm\Policy\$SID\ActualConfig -ClassName CCM_Scheduler_ScheduledMessage | Where-Object -FilterScript {$_.ScheduledMessageID -eq $Schedule}
77
82
# $ActualConfig.Triggers = @('SimpleInterval;Minutes=1;MaxRandomDelayMinutes=0')
78
83
# $ActualConfig | Set-CimInstance
@@ -90,15 +95,12 @@ function Trigger-Schedule
90
95
{
91
96
Write-Verbose - Message $Schedule - Verbose
92
97
93
- if ($Schedule -eq " {00000000-0000-0000-0000-000000000027} " ) # "Policy Agent Request Assignment" too
98
+ if (( $Schedule -eq " PolicyAgentRequestAssignment " ) -or ( $Schedule -eq " UserPolicyRetrieval " ))
94
99
{
95
- $SID = (Get-CimInstance - Namespace root\ccm - ClassName CCM_UserLogonEvents | Where-Object - FilterScript {$null -eq $_.LogoffTime }).UserSID.Replace(" -" , " _" )
96
100
$ActualConfig = Get-WmiObject - ClassName CCM_Scheduler_ScheduledMessage - Namespace root\ccm\Policy\$SID \ActualConfig | Where-Object - FilterScript {$_.ScheduledMessageID -eq $Schedule }
97
101
$ActualConfig.Triggers = @ (' SimpleInterval;Minutes=1;MaxRandomDelayMinutes=0' )
98
102
$ActualConfig.Put ()
99
103
100
- Start-Sleep - Seconds 10
101
-
102
104
# $SID = (Get-CimInstance -Namespace root\ccm -ClassName CCM_UserLogonEvents | Where-Object -FilterScript {$null -eq $_.LogoffTime}).UserSID.Replace("-", "_")
103
105
# $ActualConfig = Get-CimInstance -ClassName CCM_Scheduler_ScheduledMessage -Namespace root\ccm\Policy\$SID\ActualConfig | Where-Object -FilterScript {$_.ScheduledMessageID -eq $Schedule}
104
106
# $ActualConfig.Triggers = @('SimpleInterval;Minutes=1;MaxRandomDelayMinutes=0')
@@ -107,9 +109,41 @@ function Trigger-Schedule
107
109
else
108
110
{
109
111
Invoke-CimMethod - Namespace root\ccm - ClassName SMS_Client - MethodName TriggerSchedule - Arguments @ {sScheduleID = $Schedule }
112
+ }
113
+ }
110
114
111
- Start-Sleep - Seconds 10
115
+ <#
116
+ $SupportedSchedules = (Get-CimInstance -ClassName CCM_Scheduler_ScheduledMessage -namespace "ROOT\ccm\policy\machine\actualconfig" | Where-Object -FilterScript {$_.ScheduledMessageID -like "{00000000-0000-0000-0000-*}"}).ScheduledMessageID
117
+ foreach ($SupportedSchedule in $SupportedSchedules)
118
+ {
119
+ try
120
+ {
121
+ Invoke-CimMethod -Namespace root\ccm -ClassName SMS_Client -MethodName TriggerSchedule -Arguments @{sScheduleID = $SupportedSchedule} -ErrorAction Stop
122
+ "$SupportedSchedule success"
123
+ }
124
+ catch [Microsoft.Management.Infrastructure.CimException]
125
+ {
126
+ "$SupportedSchedule failed"
112
127
}
113
128
}
129
+ #>
114
130
}
115
131
}
132
+ <#
133
+ $Schedules = @(
134
+ "AppDeployment",
135
+ "DiscoveryData",
136
+ "FileCollection",
137
+ "HardwareInventory",
138
+ "MachinePolicyRetrieval",
139
+ "SoftwareInventory",
140
+ "SoftwareMeteringUsage",
141
+ "SoftwareUpdates",
142
+ "SoftwareUpdatesScan",
143
+ "PolicyAgentRequestAssignment",
144
+ "UserPolicyRetrievalEvalCycle",
145
+ "WindowsInstallerSourceListUpdate"
146
+ )
147
+ Trigger-Schedule -Schedules $Schedules
148
+ #>
149
+ Trigger- Schedule - All
0 commit comments