Hello Ron,
Your script is on the right track, but there are a few things to fix:
Missing Set-RDMCurrentDataSource: After retrieving the data source, you need to actually activate it. Without this call, all subsequent commands run against whatever data source was already active.
Missing validation: After setting the data source and vault, it is good practice to verify they are correctly active before proceeding. This prevents silently importing into the wrong location.
Import-RDMEntry missing -Set: Without -Set, the documents and attachments will not be included.
Here is the corrected script:
$desiredDataSourceName = "Devolutions Hub Business"
$desiredVaultName = "<Vault name>"
# 1. Get and activate the data source
$ds = Get-RDMDataSource -Name $desiredDataSourceName
Set-RDMCurrentDataSource $ds
# 2. Validate the active data source
$currentDs = Get-RDMCurrentDataSource
if ($currentDs.Name -ne $desiredDataSourceName) {
Write-Error "Data source mismatch: expected '$desiredDataSourceName', got '$($currentDs.Name)'. Aborting."
exit 1
}
# 3. Get and activate the vault
$repository = Get-RDMRepository -Name $desiredVaultName
Set-RDMCurrentRepository $repository
# 4. Validate the active vault
$currentRepo = Get-RDMCurrentRepository
if ($currentRepo.Name -ne $desiredVaultName) {
Write-Error "Vault mismatch: expected '$desiredVaultName', got '$($currentRepo.Name)'. Aborting."
exit 1
}
# 5. Import entries
$importedEntries = Import-RDMEntry -Path "<Path>\<FileName>.rdm" -Set
Write-Host "Imported $($importedEntries.Count) entries."
This script has been tested and works correctly. Just replace <Vault name>, <Path>, and <FileName> with your actual values.
Best regards,
Maxime