Security Controls

Tips and Tricks

Here are a few tips and tricks that will improve your experience with the API.

When typing PowerShell commands, use the Tab button to auto-complete the command.

Use pipelining within your commands to string together a series of actions.

If you want to view the output when performing a patch scan, be sure to use the Watch-PatchScan parameter.

Example:

Start-PatchScan –MachineGroups “Sample Group” | Watch-PatchScan

You can assign the result of any command to a variable and interact with that variable later in the same PowerShell session.

Examples:

$credReference = Get-STCredential

$credReference | Where-Object

{ $_.UserName.Contains(“foo”) }

$myScan = Start-PatchScan –MachineGroups “My Machine”

Wait-PatchScan –Uid ($myScan.Uid)

If you want to perform a patch deployment against the results of a particular patch scan, store the patch scan in a variable and pipe it to the deployment operation.

Example:

$myScan = Start-PatchScan –MachineGroups “Sample Group”;

$myScan | Watch-PatchScan

$myScan | Start-PatchDeploy –ScanUid ($MyScan.Uid) –TemplateName “Sample Deploy Template”

If you are scripting a patch scan followed by a patch deployment, be sure to use the Wait-PatchScan parameter to allow time for the scan to complete before the deployment is initiated.

Example:

$MyScan = Start-PatchScan –MachineGroups “Sample Group” | Wait-PatchScan

Start-PatchDeploy –ScanUid ($MyScan.Uid) –TemplateName “Sample Deploy Template”

Be sure to load any additional modules that might be needed.

Example: When interacting with a SQL cluster you might load the following modules:

Import-Module ServerManager

Add-WindowsFeature RSAT-Clustering

Import-Module FailoverClusters

To minimize downtime, you can use the Invoke-DownloadMissingPatches command before deploying.

This would enable you to perform a scan one day and then use the Get-PatchScan command to deploy from that scan on a different day.


Was this article useful?