Skip to main content

Windows Feature Update Attempt Tracking (Subscript)

Summary

This script is a subscript used for tracking the number of times the Windows Feature Upgrade solution has run and enters that value into the WinFeatUpgradeAttempts field.

Sample Run

The script is intended to be called from the task Feature Update Install With Tracking and should not be executed manually.

Dependencies

Create Script

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

Image

Image

Name: Windows Feature Update Attempt Tracking (Subscript)

Description: This script is a subscript used for tracking the number of times the Win Feature Upgrade solution has run and enters that value into the WinFeatUpgradeAttempts field.

Category: Patching

Image

Start by adding a row. You can do this by clicking the Add Row button at the bottom of the script page.

Image

Row 1 Function: PowerShell Script

Insert a new row by clicking the Add Row button.

Image

Select PowerShell Script function.

Image

Image

Image

Paste in the following PowerShell script, set the expected time of script execution to 300 seconds, and click the Save button.

$output='@reset@'
$output

Image

Mark the Continue on Failure checkbox.

Image

Row 2 Logic: If Then

Insert a new If/Then logic from the Add Logic dropdown menu.

Image
Image

Row 2a Condition: Output Contains

Type True in the Value box and press Enter.

Image

Row 2b Function: Script Log

Insert a new row by clicking the Add Row button inside the If Then logic after the Output Contains condition.

Image

Search and select the Script Log function in the new row.

Image

Image

Paste this line in the Script Log Message box and click the Save button.
Reset Variable = %output% Resetting WinFeatUpgradeAttempts Custom Field to 0.

Image

Image

Row 2c Function: Set Custom Field

Insert a new row by clicking the Add Row button inside the If Then logic.

Image

Image

Search and select the Set Custom Field function in the new row.

Image

Image

Search and select the WinFeatUpgradeAttempts Custom Field.

Image

Type 0 in the Value box and click the Save button.

Image

Image

Step 3 Function: Set Pre-defined Variable

Insert a new row by clicking the Add Row button.

Image

Select Set Pre-defined Variable function.

Image

Image

Type VarCheck in the Variable Name field, mark the Custom Field checkbox, select WinFeatUpgradeAttempts in the Custom Field box, and click the Save button.

Image

Image

Step 4 Function: Script Log

Insert a new row by clicking the Add Row button.

Image

Search and select the Script Log function in the new row.

Image

Image

Paste this line in the Script Log Message box and click the Save button.
Win Feature Pack Upgrade Attempts = @varcheck@

Image

Image

Row 5 Function: PowerShell Script

Insert a new row by clicking the Add Row button.

Image

Select PowerShell Script function.

Image

Image

Image

Paste in the following PowerShell script, set the expected time of script execution to 300 seconds, and click the Save button.

$Number = @VarCheck@
$Number++
$Number

Image

Mark the Continue on Failure checkbox.

Image

Step 6 Function: Script Log

Insert a new row by clicking the Add Row button.

Image

Search and select the Script Log function in the new row.

Image

Image

Paste this line in the Script Log Message box and click the Save button.
%output%

Image

Image

Row 7 Function: Set Custom Field

Insert a new row by clicking the Add Row button.

Image

Search and select the Set Custom Field function in the new row.

Image

Image

Search and select the WinFeatUpgradeAttempts Custom Field.

Image

Type %Output% in the Value box and click the Save button.

Image

Image

Click the Save button to save the task.

Image

Completed Script

Image

Image

Output

  • Script Log
  • Custom Field