functions/folders/Get-TssFolderAudit.ps1
function Get-TssFolderAudit { <# .SYNOPSIS Get a list of audits .DESCRIPTION Get a list of audit for Folder ID .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssFolderAudit -TssSession $session -Id 42 Gets the audit entries for Folder ID .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/folders/Get-TssFolderAudit .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/folders/Get-FolderAudit.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.Folders.AuditSummary')] param ( # TssSession object created by New-TssSession for authentication [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, # Folder ID [Parameter(Mandatory, ValueFromPipelineByPropertyName)] [Alias('FolderId')] [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 ($folder in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'folders', $folder, 'audit' -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $($invokeParams.Uri)" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning "Issue getting folder [$folder]" $err = $_ . $ErrorHandling $err } if ($restResponse.records) { [Thycotic.PowerShell.Folders.AuditSummary[]]$restResponse.records } } } else { Write-Warning 'No valid session found' } } } |