functions/folders/Remove-TssFolderPinned.ps1
|
function Remove-TssFolderPinned { <# .SYNOPSIS Unpin a folder for the current user .DESCRIPTION Unpins a folder for the current user and removes the settings saved for that pin. Succeeds when the folder is not pinned. .PARAMETER TssSession TssSession object created by New-TssSession for authentication .PARAMETER Id Folder ID to unpin .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Remove-TssFolderPinned -TssSession $session -Id 42 Unpins folder 42 for the current user .EXAMPLE $session = New-TssSession -SecretServer https://alpha -Credential $ssCred Get-TssFolderPinned -TssSession $session | Remove-TssFolderPinned -TssSession $session Unpins every folder the current user has pinned .LINK https://thycotic-ps.github.io/thycotic.secretserver/commands/folders/Remove-TssFolderPinned .LINK https://github.com/thycotic-ps/thycotic.secretserver/blob/main/src/functions/folders/Remove-TssFolderPinned.ps1 .NOTES Requires TssSession object returned by New-TssSession #> [CmdletBinding(SupportsShouldProcess)] [OutputType('Thycotic.PowerShell.Folders.ActionResult')] param ( [Parameter(Mandatory, ValueFromPipeline, Position = 0)] [Thycotic.PowerShell.Authentication.Session] $TssSession, [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 ($currentId in $Id) { $restResponse = $null $uri = $TssSession.ApiUrl, 'folder', $currentId, 'pinned' -join '/' $invokeParams.Uri = $uri $invokeParams.Method = 'DELETE' if ($PSCmdlet.ShouldProcess("Folder pinned: $currentId", "$($invokeParams.Method) $uri")) { Write-Verbose "Performing the operation $($invokeParams.Method) $uri" try { $apiResponse = Invoke-TssApi @invokeParams $restResponse = . $ProcessResponse $apiResponse } catch { Write-Warning 'Issue with Remove-TssFolderPinned request' $err = $_ . $ErrorHandling $err } if ($restResponse) { [Thycotic.PowerShell.Folders.ActionResult](. $FilterTssResponse $restResponse ([Thycotic.PowerShell.Folders.ActionResult])) } } } } else { Write-Warning 'No valid session found' } } } |