functions/discovery/Set-TssDiscoverySourceScannerOrder.ps1
|
function Set-TssDiscoverySourceScannerOrder { <# .SYNOPSIS Set the run order of the scanners of a discovery source .DESCRIPTION Sets the order in which the scanners of a discovery source run. Pass the scanner IDs of the source in the order they should run. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id Discovery source ID .PARAMETER DiscoveryItemScannerId Scanner IDs of the source, in run order .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Set-TssDiscoverySourceScannerOrder -TssSession $session -Id 3 -DiscoveryItemScannerId 12, 15, 9 Run scanner 12, then 15, then 9 on discovery source 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/discovery/Set-TssDiscoverySourceScannerOrder .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/discovery/Set-TssDiscoverySourceScannerOrder.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding(SupportsShouldProcess)] [OutputType('Thycotic.PowerShell.Discovery.OperationResult')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('DiscoverySourceId')] [int] $Id, [Parameter(Mandatory)] [int[]] $DiscoveryItemScannerId ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '10.9.000000' $PSCmdlet.MyInvocation $uri = $TssSession.ApiUrl, 'discovery', 'source', $Id, 'scanners', 'sort' -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'POST' $body = @{ data = @{ } } switch ($tssParams.Keys) { 'DiscoveryItemScannerId' { $body.data.Add('discoveryItemScannerIds', $DiscoveryItemScannerId) } } $invokeParams.Body = $body | ConvertTo-Json -Depth 100 if ($PSCmdlet.ShouldProcess("Discovery source scanner order: $Id", "$($invokeParams.Method) $uri with:`n$($invokeParams.Body)`n")) { Write-Verbose "Performing the operation $($invokeParams.Method) $uri with:`n$($invokeParams.Body)`n" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Set-TssDiscoverySourceScannerOrder request' $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.Discovery.OperationResult](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.Discovery.OperationResult])) } } } else { Write-Warning 'No valid session found' } } } |