# The example shows how to add a Safe Box Group and Safe Boxes into 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 and CREATE) only # for the Root level instead. $sabUrl = "http://127.0.0.1/sab" ## enter Url of SecureAnyBox $loginStatus = Connect-SAB $sabUrl try { # 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, 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 creating a Safe Box Group and Safe Boxes. Set-AccessCode -Timeout 60 ## == value of timeout in seconds # Set the names of new Safe Boxes $safeBoxGroupName = "Group2" ## enter name of new Safe Box Group $safeBoxName = "SafeBox1" ## enter name of new Safe Box in the Safe Box Group $rootSafeBoxName = "SafeBoxInRoot" ## enter name of new Safe Box at the Root level # To add any Safe Box, we need to know the id of the parent Safe Box Group. # If adding a Safe Box to the Root level, parent id parameter can be null (0) or empty. # A Safe Box Group can create only at the Root level. $safe_Box_group = [pscustomobject]@{ Type = 'SAFEBOX_GROUP'; Name = $safeBoxGroupName } $groupId = $safe_Box_group | Add-SafeBox | Select-Object -Expand id Write-Host "Safe Box Group '$safeBoxGroupName' added to the Root level" if ( $groupId -gt 0 ) { $safe_Box = [pscustomobject]@{ Type = 'SAFEBOX'; Name = $safeBoxName } $safe_Box | Add-SafeBox -Id $groupId Write-Host "Safe Box '$safeBoxName' added to the '$safeBoxGroupName' Safe Box Group" } $safe_Box = [pscustomobject]@{ Type = 'SAFEBOX'; Name = $rootSafeBoxName } $safe_Box | Add-SafeBox Write-Host "Safe Box '$rootSafeBoxName' added to Root level" } finally { # When the connection is not needed anymore, disconnect from the SecureAnyBox server. # The client can no longer be used to work with the SecureAnyBox server. Disconnect-SAB }