Functions/Safes/Remove-PVSafeOwner.ps1
Function Remove-PVSafeOwner { <# .SYNOPSIS Deletes a Safe Owner, thus removing their permissions and authority to enter the Safe. In order to carry out this command successfully, the Safe must be open. .DESCRIPTION Exposes the PACLI Function: "DELETEOWNER" .PARAMETER vault The defined Vault name .PARAMETER user The Username of the authenticated User. .PARAMETER owner The name of the Safe Owner to remove from the Vault. .PARAMETER safe The name of the Safe from which to remove the Safe Owner. .PARAMETER sessionID The ID number of the session. Use this parameter when working with multiple scripts simultaneously. The default is ‘0’. .EXAMPLE Remove-PVSafeOwner -vault lab -user administrator -safe EU_Safe -owner user1 Deletes user1 as a safe member on EU_Safe .NOTES AUTHOR: Pete Maan #> [CmdLetBinding(SupportsShouldProcess)] [Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSShouldProcess", "", Justification = "ShouldProcess handling is in Invoke-PACLICommand")] param( [Parameter( Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$vault, [Parameter( Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [string]$user, [Parameter( Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [Alias("Safename")] [string]$safe, [Parameter( Mandatory = $True, ValueFromPipelineByPropertyName = $True)] [Alias("Username")] [String]$owner, [Parameter( Mandatory = $False, ValueFromPipelineByPropertyName = $True)] [int]$sessionID ) PROCESS { $Return = Invoke-PACLICommand $Script:PV.ClientPath DELETEOWNER $($PSBoundParameters.getEnumerator() | ConvertTo-ParameterString) if($Return.ExitCode -eq 0) { Write-Verbose "Removed Safe Owner: $owner" [PSCustomObject] @{ "vault" = $vault "user" = $user "sessionID" = $sessionID } | Add-ObjectDetail -TypeName pacli.PoShPACLI } } } |