Skip to main content

Out of Date Cumulative Update (Autofix)

Summary

Installs the latest available Cumulative Update on the machines where a CU has not been installed in the last 75 days.

Sample Run

Sample Run 1
Sample Run 2

Dependencies

Variables

NameDescription
Company_SelectionValue stored in the Company - Out_of_Date_CU_Autofix Custom Field.
Site_SelectionValue stored in the Site - Out_of_Date_CU_Autofix Custom Field.
Endpoint_SelectionValue stored in the EndPoint - Out_of_Date_CU_Autofix Custom Field.
OutputOutput of the previously executed PowerShell script.

Task Creation

Create a new Script Editor style script in the system to implement this Task.

Task Creation Image 1
Task Creation Image 2

Name: Out of Date Cumulative Update (Autofix)
Description: Installs the latest available Cumulative Update on the machines where a CU has not been installed in the last 75 days.
Category: Patching

Task Creation Image 3

Task

Navigate to the Script Editor Section and start by adding a row. You can do this by clicking the Add Row button at the bottom of the script page.
Add Row

A blank function will appear.
Blank Function

Row 1 Function: Set Pre-defined Variable

Search and select the Set Pre-defined Variable function.
Set Pre-defined Variable
Select Function

The following function will pop up on the screen:
Function Popup

  • Type Company_Selection in the Variable Name field.
  • Select the Custom Field radio button.
  • Search and select the company-level Out_of_Date_CU_Autofix Custom Field in the Search Custom Field field.
  • Click the Save button to save the changes.
    Save Changes
    Save Confirmation

Row 2 Function: Set Pre-defined Variable

Add a new row by clicking on the Add Row button.
Add Row

A blank function will appear.
Blank Function

Search and select the Set Pre-defined Variable function.
Set Pre-defined Variable
Select Function

The following function will pop up on the screen:
Function Popup

  • Type Site_Selection in the Variable Name field.
  • Select the Custom Field radio button.
  • Search and select the site-level Out_of_Date_CU_Autofix Custom Field in the Search Custom Field field.
  • Click the Save button to save the changes.
    Save Changes
    Save Confirmation
    Save Confirmation
    Save Confirmation

Row 3 Function: Set Pre-defined Variable

Add a new row by clicking on the Add Row button.
Add Row

A blank function will appear.
Blank Function

Search and select the Set Pre-defined Variable function.
Set Pre-defined Variable
Select Function

The following function will pop up on the screen:
Function Popup

  • Type Endpoint_Selection in the Variable Name field.
  • Select the Custom Field radio button.
  • Search and select the Endpoint-level Out_of_Date_CU_Autofix Custom Field in the Search Custom Field field.
  • Click the Save button to save the changes.
    Save Changes
    Save Confirmation
    Save Confirmation
    Save Confirmation

Row 4 Function: PowerShell Script

Add a new row by clicking on the Add Row button.
Add Row

A blank function will appear.
Blank Function

Search and select the PowerShell Script function.
PowerShell Script
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following PowerShell script and leave the expected time of script execution to 300 seconds. Click the Save button.

$os = ( Get-CimInstance -ClassName Win32_OperatingSystem ).Caption
if ( '@EndPoint_Selection@' -eq 'Enable' ) {
'Enable'
} elseif ( '@EndPoint_Selection@' -eq 'Disable' ) {
'Disable'
} elseif ( $os -match 'Server' ) {
if ( '@Site_Selection@' -eq 'Enable for Server' ) {
'Enable'
} elseif ( '@Site_Selection@' -eq 'Disable for Server' ) {
'Disable'
} elseif ( '@Company_Selection@' -eq 'Servers as well' ) {
'Enable'
} else {
'Disable'
}
} elseif ( '@Site_Selection@' -eq 'Enable' ) {
'Enable'
} elseif ( '@Site_Selection@' -eq 'Disable' ) {
'Disable'
} elseif ( '@Company_Selection@' -eq 'Enable' ) {
'Enable'
} elseif ( '@Company_Selection@' -eq 'Disable' ) {
'Disable'
} else {
'Disable'
}

PowerShell Script

Row 5 Logic: If/Then

Logic

A blank function will appear.
Blank Function

Row 5a Condition: Output Contains

Type Disable in the Input Value or Variable field and press Enter.
Output Contains

Row 5b Function: Script Log

Click the Add Row button inside the If/Then logic.
Add Row

Search and select the Script Log function in the newly appeared row.
Script Log
Select Function

The following function will pop up on the screen:
Function Popup

Type Autofix is disabled. in the Script Log Message field and click the Save button.
Save Changes

Row 5c Function: Script Exit

Click the Add Row button inside the If/Then logic.
Add Row

Search and select the Script Exit function in the newly appeared row.
Script Exit
Select Function

The following function will pop up on the screen:
Function Popup

Click the Save button without typing anything in the Error Message field.
Save Changes

Row 6 Function: PowerShell Script

Add a new row by clicking on the Add Row button outside the If/Then logic.
Add Row

A blank function will appear.
Blank Function

Search and select the PowerShell Script function.
PowerShell Script
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following PowerShell script and set the expected time of script execution to 7200 seconds. Click the Save button.

# Needs update to JSON format

PowerShell Script

Row 7 Logic: If/Then/Else

Logic
Logic

Row 7a Condition: Output Contains

Type Failed to Install in the Input Value or Variable field and press Enter.
Output Contains

Row 7b Function: Set Custom Field

Add a new row by clicking the Add Row button inside the If section.
Add Row

Search and select the Set Custom Field function.
Set Custom Field
Select Function

Search and select Out_of_Date_CU_Autofix_Result in the Search Custom Field field and set Failed in the Value field, then click the Save button.
Save Changes
Save Confirmation

Row 7c Function: Script Exit

Click the Add Row button inside the If/Then logic.
Add Row

Search and select the Script Exit function in the newly appeared row.
Script Exit
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following lines in the Error Message field and click the Save button.

Script Failed.  
Output: %Output%

Save Changes

Row 7d Logic: If/Then/Else

Add a new If/Then/Else logic inside the Else section.
Logic
Logic

Row 7d(i) Condition: Output Contains

Change the comparator to Does Not Contain.
Change Comparator

Type Successfully installed the latest available Cumulative Update in the Input Value or Variable field and press Enter.
Input Value

Row 7d(ii) Function: Script Log

Click the Add Row button after the condition.
Add Row

Search and select the Script Log function in the newly appeared row.
Script Log
Select Function

The following function will pop up on the screen:
Function Popup

Type Script Result: %Output% in the Script Log Message field and click the Save button.
Save Changes

Row 7d(iii) Function: Script Exit

Click the Add Row button inside the If/Then logic.
Add Row

Search and select the Script Exit function in the newly appeared row.
Script Exit
Select Function

The following function will pop up on the screen:
Function Popup

Click the Save button without typing anything in the Error Message field.
Save Changes

Row 7d(iv) Logic: If/Then/Else

Add a new If/Then/Else logic inside the Else section.
Logic
Logic

Row 7d(iv)1 Condition: Output Does Not Contain

Change the comparator to Does Not Contain.
Change Comparator

Type Successfully installed the latest available Cumulative Update in the Input Value or Variable field and press Enter.
Input Value

Row 7d(iv)2 Function: Set Custom Field

Add a new row by clicking the Add Row button inside the If section.
Add Row

Search and select the Set Custom Field function.
Set Custom Field
Select Function

Search and select Out_of_Date_CU_Autofix_Result in the Search Custom Field field and set Failed in the Value field, then click the Save button.
Save Changes
Save Confirmation

Row 7d(iv)3 Function: Script Exit

Click the Add Row button inside the If section.
Add Row

Search and select the Script Exit function in the newly appeared row.
Script Exit
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following lines in the Error Message field and click the Save button.

Script Failed.  
Output: %Output%

Save Changes

Row 7d(iv)4 Function: Set Custom Field

Add a new row by clicking the Add Row button inside the Else section.
Add Row

A blank function will appear.
Blank Function

Search and select the Set Custom Field function.
Set Custom Field
Select Function

Search and select Out_of_Date_CU_Autofix_Result in the Search Custom Field field and set Reboot Pending in the Value field, then click the Save button.
Save Changes
Save Confirmation

Row 7d(iv)5 Function: PowerShell Script

Add a new row by clicking the Add Row button inside the Else section.
Add Row

A blank function will appear.
Blank Function

Search and select the PowerShell Script function.
PowerShell Script
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following PowerShell script and leave the expected time of script execution to 300 seconds. Click the Save button.

(Get-Date).ToString('yyyy-MM-dd HH:mm:ss')

PowerShell Script

Row 7d(iv)6 Function: Set Custom Field

Add a new row by clicking the Add Row button inside the Else section.
Add Row

A blank function will appear.
Blank Function

Search and select the Set Custom Field function.
Set Custom Field
Select Function

Search and select Out_of_Date_CU_Autofix_Date in the Search Custom Field field and set %Output% in the Value field, then click the Save button.
Save Changes
Save Confirmation

Row 7d(iv)7 Function: PowerShell Script

Add a new row by clicking the Add Row button inside the Else section.
Add Row

A blank function will appear.
Blank Function

Search and select the PowerShell Script function.
PowerShell Script
Select Function

The following function will pop up on the screen:
Function Popup

Paste the following PowerShell script and leave the expected time of script execution to 300 seconds. Click the Save button.

$os = ( Get-CimInstance -ClassName Win32_OperatingSystem ).Caption; 
if ( $os -match 'Server' ) {
'This is a Server Operating System. It should be restarted manually. Exiting the Script.'
} else {
'Initiating the reboot pending prompt solution on the machine.'
}

PowerShell Script

Row 7d(iv)8 Function: Script Log

Add a new row by clicking the Add Row button inside the Else section.
Add Row

A blank function will appear.
Blank Function

Search and select the Script Log function in the newly appeared row.
Script Log
Select Function

The following function will pop up on the screen:
Function Popup

Type %Output% in the Script Log Message field and click the Save button.
Save Changes

Row 7d(v) Logic: If/Then

Add a new If/Then logic inside the Else section of the previous logic.
Image
Image

Row 7d(v)1 Condition: Custom Field Equal

Select the Custom Field option from the DropDown button.
Image

Search and select the Out_of_Date_CU_Autofix_Result custom field.
Image

Change the operator to Equals , type Reboot Pending in the comparator and press Enter.
Image

Add another Condition by clicking the Add Condition button.
Image
Image

Type Initiating the reboot pending prompt solution on the machine in the Input value or variable field and press Enter.
Image

Row 7d(v)2 Function: Set Custom Field

Add a new row by clicking the Add Row button inside the Else section.
Image

A blank function will appear.

Search and select Set Custom Field Function.
Image
Image

Search and select Prompter_RebootPending in the Search Custom Field field and set True in the Value field and click the Save button.
Image
Image

Mark the Continue on Failure Check-Box.
Image

Click the Save button at the top-right corner of the screen to save the script.
Image

Completed Script

Completed Script 1
Completed Script 2
Completed Script 3
Completed Script 4

Deployment

It is suggested to run the Task once per week against the Out of Date CU _ Autofix Required device group.

  1. Go to Automation > Tasks.
  2. Search for Out of Date Cumulative Update (Autofix) Task.
  3. Select the concerned task.
  4. Click on the Schedule button to schedule the task.
    Schedule Task
  5. This screen will appear.
    Schedule Screen
  6. Click the Does not repeat button.
    Does Not Repeat
  7. This pop-up box will appear.
    Pop-up Box
  8. Change the Repeat interval to Week(s), select an appropriate day; I have selected Monday in the attached screenshot. Click the OK button to save the changes.
    Change Repeat Interval
  9. Recurrence will be updated to Every Week on \<Selected Weekday>.
    Recurrence Updated
  10. Select the Device Groups option in the Targeted Resources section.
    Targeted Resources
  11. Search and Select the Out of Date CU _ Autofix Required device group.
    Select Device Group
  12. Now click the Run button to initiate the task.
    Run Task
  13. The task will start appearing in the Scheduled Tasks.
    Scheduled Tasks
    Scheduled Tasks

Output

  • Script Log
  • Custom Field