Skip to main content

Out of Date Cumulative Update (Post Reboot Verification)

Summary

This task validates whether the Cumulative Update installed by the Out of Date Cumulative Update (Autofix) task succeeded post-reboot.

Sample Run

Sample Run 1
Sample Run 2

Dependencies

Variables

NameDescription
TaskRunTimeValue stored in the EndPoint - Out_of_Date_CU_Autofix_Date 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.
Create Script
Create Script 2

Name: Out of Date Cumulative Update (Post Reboot Verification)
Description: This task validates whether the Cumulative Update installed by the Out of Date Cumulative Update (Autofix) task succeeded post-reboot.
Category: Patching
Task Category

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 1
Set Pre-defined Variable 2

The following function will pop up on the screen:
Set Pre-defined Variable Function

  • Type TaskRunTime in the Variable Name field.
  • Select the Custom Field radio button.
  • Search and select the company-level Out_of_Date_CU_Autofix_Date custom field in the Search Custom Field field.
  • Click the Save button to save the changes.
    Save Changes 1
    Save Changes 2

Row 2 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 1
PowerShell Script 2

The following function will pop up on the screen:
PowerShell Script Function

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

$TaskRunTime = '@TaskRunTime@'
if ( $TaskRunTime -eq '0001-01-01 00:00:00' ) {
return 'Exit'
} else {
$Uptime = ( systeminfo | Find 'System Boot Time' )
if ( $Uptime -match '([0-9]{1,2}\/[0-9]{1,2}\/[0-9]{4}, [0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2})' ) {
$uptime = $Matches[1]
}
$uptime = $uptime -replace '\/', '-' -replace ',', ''
if ( [DateTime]$uptime -ge [DateTime]$TaskRunTime ) {
return 'Rebooted'
} else {
return 'Still Pending'
}
}

PowerShell Script Example

Row 3 Logic: If/Then/Else

If/Then/Else Logic
If/Then/Else Logic 2

Row 3a Condition: Output Does Not Contain

Change the comparator to Does Not Contain.
Output Does Not Contain

Type Rebooted in the Input Value or Variable field and press Enter.
Input Value

Row 3b Function: Script Log

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

A blank function will appear.
Blank Function

Search and select the Script Log function in the newly appeared row.
Script Log 1
Script Log 2

The following function will pop up on the screen:
Script Log Function

Type Still reboot pending in the Script Log Message field and click the Save button.
Save Script Log

Row 3c Function: Script Exit

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

Search and select the Script Exit function in the newly appeared row.
Script Exit 1
Script Exit 2

The following function will pop up on the screen:
Script Exit Function

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

Row 3d Script: Cumulative Update Audit

Click the Add Row button in the Else section.
Add Row in Else
Add Row in Else 2

Change the Function to Script from the dropdown.
Change Function to Script

Search and select the Cumulative Update Audit script.
Cumulative Update Audit 1
Cumulative Update Audit 2

Row 3e Logic: If/Then/Else

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

Row 3e(i) Condition: Custom Field Contains

Select the Custom Field from the dropdown menu.
Custom Field Dropdown
Custom Field Selection

Search and select the Latest Cumulative Update custom field and type Failed in the comparator and press Enter.
Latest Cumulative Update Condition

Row 3e(ii) Function: Set Custom Field

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

Search and select the Set Custom Field function.
Set Custom Field 1
Set Custom Field 2

Search and select Out_of_Date_CU_Autofix_Result in the Search Custom Field field and set Failed in the Value field and click the Save button.
Set Custom Field Example 1
Set Custom Field Example 2

Row 3e(iii) Function: Script Exit

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

Search and select the Script Exit function in the newly appeared row.
Script Exit 1
Script Exit 2

The following function will pop up on the screen:
Script Exit Function

Paste the following lines in the Error Message field and click the Save button.
Cumulative Update Failed to install after restarting the computer as well.
Save Error Message

Row 3e(iv) Function: Set Custom Field

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

Search and select the Set Custom Field function.
Set Custom Field 1
Set Custom Field 2

Search and select Out_of_Date_CU_Autofix_Result in the Search Custom Field field and set Installed in the Value field and click the Save button.
Set Custom Field Example 1
Set Custom Field Example 2

Row 3e(v) Function: Set Custom Field

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

Search and select the Set Custom Field function.
Set Custom Field 1
Set Custom Field 2

Search and select Out_of_Date_CU_Autofix_Date in the Search Custom Field field and set 0001-01-01 00:00:00 in the Value field and click the Save button.
Set Custom Field Example 1
Set Custom Field Example 2

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

Completed Script

Completed Script 1
Completed Script 2

Deployment

It is suggested to run the task once per day against the Out of Date CU _ Reboot Pending device group.

  • Go to Automation > Tasks.
  • Search for Out of Date Cumulative Update (Post Reboot Verification) task.
  • Select the concerned task.
  • Click on the Schedule button to schedule the task.
    Schedule Task

This screen will appear.
Schedule Screen

Click the Does not repeat button.
Does Not Repeat

This pop-up box will appear.
Pop-up Box

Click the OK button without making any changes to set it to run once per day.
OK Button

Recurrence will be updated to Every Day.
Every Day

Select the Device Groups option in the Targeted Resources section.
Targeted Resources

Search and select the Out of Date CU _ Reboot Pending device group.
Device Group Selection

Now click the Run button to initiate the task.
Run Task

The task will start appearing in the Scheduled Tasks.
Scheduled Tasks 1
Scheduled Tasks 2

Output

  • Script Log
  • Custom Field