# The example shows how to view the fields of records from specific SecureAnyBox. # If you want to use PowerShell commands to work with SecureAnyBox, first # install SecureAnyBoxPowerShellModule.msi # First, we need to authenticate the user. Connect-Sab command connects to SecureAnyBox and # opens the login dialogue. # Due to security reasons, we strongly recommend not using an admin user account. # Create (or use) a user account with minimum permissions (READ) only # for the specific Safe Box 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 the Safe Box, # from which records field values should be shown. # 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, it is necessary to # check if the received id is valid and the script can continue $safeBoxName = 'safebox_name' ## enter the name of Safe Box $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)" # Powershell function Set-AccessCode prompts the user to enter the Access Code # and store it on the SecureAnyBox server for a specified amount of seconds. # A stored Access Code allows viewing secure fields of the record. Set-AccessCode -Timeout 60 ## == value of timeout in seconds # PowerShell commands Get-Records and Get-Record # are used to retrieve an array of records from specified Safe Box. # The Get-Records cmdlet returns all records from the Safe Box, but does not return all fields. # The Get-Record command returns all record fields (because the access code was stored in previous step) $records = $boxId | Get-Records | Get-Record foreach ( $recItem in $records ) { $recItem Write-Host "----------------------------------------------------------------------------"`n } Write-Host `n"Printed" $records.Count "records"