functions/secret-policies/Get-TssSecretPolicyAudit.ps1
|
function Get-TssSecretPolicyAudit { <# .SYNOPSIS Get the audit trail of a Secret Policy .DESCRIPTION Returns one entry per change made to a Secret Policy: who made it, when, the action, and any notes. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id Secret Policy ID .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssSecretPolicyAudit -TssSession $session -Id 4 Returns the audit entries for Secret Policy ID 4 .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Search-TssSecretPolicy -TssSession $session -PolicyName 'Windows' -IncludeInactive | Get-TssSecretPolicyAudit -TssSession $session Returns the audit entries for every Secret Policy with "Windows" in the name .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/secret-policies/Get-TssSecretPolicyAudit .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/secret-policies/Get-TssSecretPolicyAudit.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.SecretPolicies.Audit[]')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('SecretPolicyId')] [int[]] $Id ) begin { $tssParams = $PSBoundParameters $invokeParams = . $GetInvokeApiParams $TssSession } process { Get-TssInvocation $PSCmdlet.MyInvocation if ($tssParams.ContainsKey('TssSession') -and $TssSession.IsValidSession()) { Compare-TssVersion $TssSession '11.0.000005' $PSCmdlet.MyInvocation foreach ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'secret-policy', $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-TssSecretPolicyAudit request' $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.SecretPolicies.Audit[]](. $FilterTssResponse $restResponse.records ([Thycotic.PowerShell.SecretPolicies.Audit])) } } } else { Write-Warning 'No valid session found' } } } |