functions/secret-templates/Get-TssSecretTemplateFolder.ps1
function Get-TssSecretTemplateFolder { <# .SYNOPSIS Get Secret Templates allowed on a given folder .DESCRIPTION Get Secret Templates allowed on a given folder .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssSecretTemplateFolder -TssSession $session -FolderId 64 Returns a list of Secret Templates allowed for Folder ID 64 .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/secret-templates/Get-TssSecretTemplateFolder .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/secret-templates/Get-TssSecretTemplateFolder.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding()] [OutputType('Thycotic.PowerShell.SecretTemplates.View')] param ( # TssSession object created by New-TssSession for authentication [Parameter(Mandatory,ValueFromPipeline,Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, # Folder ID [Parameter(Mandatory,ValueFromPipelineByPropertyName)] [int[]] $FolderId ) 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 $FolderId) { $restResponse = $null $uri = $TssSession.ApiUrl, 'templates', $folder -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'GET' Write-Verbose "Performing the operation $($invokeParams.Method) $uri with $body" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning "Issue getting templates on [$folder]" $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.SecretTemplates.View[]]$restResponse } } } else { Write-Warning "No valid session found" } } } |