functions/diagnostics/Clear-TssCache.ps1
|
function Clear-TssCache { <# .SYNOPSIS Clear the Secret Server application cache .DESCRIPTION Clears the Secret Server application cache without an IIS reset, the same as the Clear Cache button under Admin, Diagnostics. Use it when templates, sites or configuration settings look stale after a change made outside the application. Active user sessions are not affected. Returns an object whose Success property is True when the cache was cleared. Requires the Administer Configuration permission. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Clear-TssCache -TssSession $session Clear the application cache .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/diagnostics/Clear-TssCache .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/diagnostics/Clear-TssCache.ps1 .NOTES Requires TssSession object returned by New-TssSession Secret Server on-premises only (the endpoint is blocked in Secret Server Cloud). #> [CmdletBinding(SupportsShouldProcess)] [OutputType('Thycotic.PowerShell.Diagnostics.OperationResult')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession ) 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, 'diagnostics', 'clear-cache' -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'POST' if ($PSCmdlet.ShouldProcess("Cache", "$($invokeParams.Method) $uri")) { Write-Verbose "Performing the operation $($invokeParams.Method) $uri" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Clear-TssCache request' $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.Diagnostics.OperationResult](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.Diagnostics.OperationResult])) } } } else { Write-Warning 'No valid session found' } } } |