How to Add a Patch Using PowerShell
Last updated on July 30, 2021.
Last Reviewed and Approved on PENDING REVIEW
Introduction
This document describes the step-by-step PowerShell instructions for:
- Adding a patch without a patch stream.
- Adding a patch to a patch stream.
- Update the patches in a patch stream.
For instructions on how to create a patch using the RPS User Interface, see How to Create a Patch Stream.
Note
Users may see "patch" and "package" used interchangeably in the log outputs during this process.
Prerequisites
Open a PowerShell window as an Administrator.
Note
User must be a Global Admin, Patch Admin, or Patch Creator.
Change your directory to the RPS ContentStore. For example:
cd C:\ContentStore
Note
The ContentStore directory location is user changeable. The current ContentStore directory location can be determined using the following PowerShell snippet:
(Get-RpsLocalNode).ContentPath
Import the RPS API module.
Import-Module C:\ContentStore\Rps-Api
Note
The ContentStore directory location is user changeable. The current ContentStore directory location can be determined with the following PowerShell snippet:
(Get-RpsLocalNode).ContentPath
New-RpsPatch
PowerShell cmdlet that is used to create a new RPS Patch.
For more information on patches, see How to Create an RPS Patch. For instructions on how to create a patch stream using PowerShell, see How to Load a Patch Stream.
Parameters
Parameter Name | Type | Description | Required |
---|---|---|---|
Path | string | Path of the patch. | False |
PatchStream | string | Patch Stream object that the patch will be added to. | False |
Adding a Patch
Follow the Prerequisite steps to add the RPS PowerShell API module.
Add the patch, without or with a patch stream, using the
New-RpsPatch
cmdlet and parameters mentioned, above.a. Add a patch without a patch stream example:
New-RpsPatch -Path C:\Patches\myPatch.zip
b. Add a patch with a patch stream example:
New-RpsPatch -Path C:\Patches\myPatch.zip -PatchStream $myPatchestream1
After the Patch command has been executed, the following will happen:
The patch item will be added to the CMDB.
The patch file will be copied in to the CDN directory, so it is able to replicate across the CDN.
Get-RpsPatch
PowerShell cmdlet that gets an RPS Patch that has been added to the CMDB using the New-RPSPatch
cmdlet.
Parameters
Parameter Name | Type | Description | Required |
---|---|---|---|
Id | GUID | ID of the patch in CMDB. | False |
Get-RpsPatchStream
PowerShell cmdlet that gets an RPS Patch Stream that has been added using the New-RpsPatchStream
cmdlet.
For instructions on how to create a patch stream using PowerShell, see How to Load a Patch Stream.
Parameters
Parameter Name | Type | Description | Required |
---|---|---|---|
Id | GUID | ID of the patch in CMDB. | False |
Update the Patches in a Patch Stream
Follow the Prerequisite steps to add the RPS PowerShell API module.
Retrieve the patches you would like to set for the patch stream by using the
Get-RpsPatch
cmdlet.$myFirstPatch = Get-RpsPatch -Id <GUID> $mySecondPatch = Get-RpsPatch -Id <GUID> $myThirdPatch = Get-RpsPatch -Id <GUID>
Assign the patches to a collection.
$myPatches = $myFirstPatch, $mySecondPatch, $myThirdPatch
Retrieve the patch stream you'd like to add the patches to by using the
Get-RpsPatchStream
cmdlet.$myPatchstream = Get-RpsPatchStream -Id <GUID>
Add those patches to the patch stream using the
Add-RpsPatch
cmdlet and passing in your collection of patches to the-Patch
parameter.Add-RpsPatch -PatchStream $myPatchstream -Patch $myPatches
Note
To replace all patches in a patch stream use the
-Force
parameter. This is "make it so" behavior. The collection of patches passed toAdd-RpsPatch
will become the only patches in the patch stream if the-Force
switch parameter is used.Add-RpsPatch -PatchStream $myPatchstream -Patch $myPatches -Force