# The example shows how to delete record from an specific Safe Box in SecureAnyBox # If you want to use PowerShell commands to work with SecureAnyBox, first # install SABPowerShellModule.msi # First we need to authenticate the user. Connect-Sab command connects to SecureAnyBox and # opens the login dialog. # Due to security reasons we strongly recommend not using an admin user account. # Create (or use) a user account with minimum permissions (READ and DELETE) only # for the Safe Box, from which the records will delete, instead. $sabUrl = "http://127.0.0.1/sab" ## enter Url of SecureAnyBox $loginStatus = connect-sab $sabUrl # If the second-factor authentication is required, the set-2fa function # opens a dialogue for entering the code if ( $loginStatus.SecondFactorRequired ) { set-2fa } # After the user logs in, it is necessary to get the id of Safe Box, # from which the records will delete. # PowerShell commands get-safeboxes and where-object are used to get Safe Box id # for a given Safe Box name. # When the response from the SecureAnyBox server is received, validation is # necessary if the received id is valid and the script can continue $safeBoxName = 'safebox_name' ## enter the name of Safe Box from which the record will delete $safeBoxId = get-safeboxes | where-object { $_.name -like $safeBoxName -and $_.Type -eq 'SAFEBOX' } | select -expand id if ( $safeBoxId -le 0 ) { Write-Host "Safe Box' $safeBoxName 'not found." exit } Write-Host "Safe Box '$safeBoxName' found. (id $safeBoxId)" # After the id of the Safe Box is known, it is possible to find a record to delete. # PowerShell commands get-records and where-object are used to get record id # for a given record name. # When the response from the SecureAnyBox server is received, validation is # necessary if the received id is valid, and the script can continue $recordName = 'record_name' ## enter the name of record to delete $recordId = get-records -Id $safeBoxId | where-object { $_.name -like $recordName } | select -expand id if ( $recordId -le 0 ) { write-host "Record ' $recordName ' was not found." exit } write-host "Record ' $recordName ' found. (id $recordId)" # PowerShell command remove-record delete record from the Safe Box Remove-Record -Id $recordId write-host "Record removed" write-host