functions/distributed-engines/Get-TssDistributedEngineSiteAudit.ps1
|
function Get-TssDistributedEngineSiteAudit { <# .SYNOPSIS Get the audit history of a Distributed Engine site .DESCRIPTION Gets the audit records of a site, newest first: action, date, notes and user. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id Site ID .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssDistributedEngineSiteAudit -TssSession $session -Id 3 Gets the audit history of site 3 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/distributed-engines/Get-TssDistributedEngineSiteAudit .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/distributed-engines/Get-TssDistributedEngineSiteAudit.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.DistributedEngines.SiteAudit[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('SiteId')] [int[]] $Id ) 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 foreach ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'distributed-engine', 'site', $currentId, 'audit' -join '/' $queryParams = @() $queryParams += "take=$($TssSession.Take)" if ($queryParams) { $uri = $uri, ($queryParams -join '&') -join '?' } $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $uri" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Get-TssDistributedEngineSiteAudit request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.DistributedEngines.SiteAudit[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.DistributedEngines.SiteAudit])) } } } else { Write-Warning 'No valid session found' } } } |