Sometimes, you want to hand over an .rtsz file but strip all passwords before doing that.
This can be quickly done by using the following PowerShell script.

Make sure you:

  • configure the script by adapting the variables
  • always work with a copy of the .rtsz file so that unintended changes don't destroy your file

Please note that the following variables need to be altered:

  • "$documentPath" = The path to your .rtsz file
  • "$outDocumentPath" = The path to the new password stripped .rtsz file
  • "$documentPasswordPlain" = The current password used to lock the .rtsz file 


# Unmark the following line if you want to use the module which ships with Royal TS V4
# If so, remove the Install-Module and Import-Module command below
# Import-Module "${env:ProgramFiles(x86)}\\Royal TS V4\RoyalDocument.PowerShell.dll"

Install-Module -Name RoyalDocument.PowerShell -Scope CurrentUser
Import-Module -Name RoyalDocument.PowerShell

# configuration of the script
$documentPath = "document.rtsz"
$outDocumentPath = "document_cleaned.rtsz"
$documentPasswordPlain = "pwd_to_open_doc"
$newPassword = ""

# create a RoyalStore in memory
$royalStore = New-RoyalStore -UserName ($env:USERDOMAIN + '\' + $env:USERNAME)

# load a RoyalDocument in memory
$documentPassword = $documentPasswordPlain | ConvertTo-SecureString -Force -AsPlainText
$royalDocument = Open-RoyalDocument -Store $royalStore -FileName $documentPath -Password $documentPassword

# get all password properties and change the password
$passwords = $royalDocument.GetAllPasswordProperties()
foreach ($p in $passwords)
    $obj = $p.Item1
    $pwd = $p.Item2

        $obj.SetPropertyValue($pwd, $newPassword)
        Write-Host "Resetting password for $($obj.Name) for $($pwd.Name)"

Out-RoyalDocument -Document $royalDocument -FileName $outDocumentPath
Close-RoyalDocument -Document $royalDocument