Hello there,
We are currently facing an issue with creating a repository using a PowerShell script.
Once the script has performed its work (create repo, import data, set role assignements), all groups become unavailable for a few minutes (Administration > User Groups List is empty), and thus non of our users are able to use RDM, as all repositories disappear.
If I flush the cache in the admin panel the issue resolves immediately instead of after a few minutes.
Please let me know if and what logs you need from me to troubleshoot this. (I'm an engineer without access to the file system of the VM that runs the application or database. If you can point me to exact locations that would be appreciated)
Relevant snippet from Powershell:
function New-RepositoryFromTemplate {
param (
[string]$NewRepositoryName,
[string]$TemplateRepositoryName,
[string]$TemplateExportFile, # optional path to cached template export
[string[]]$AllowedRoles
)
try {
$templateRepo = Get-RDMRepository -ErrorAction SilentlyContinue | Where-Object { $_.Name -eq $TemplateRepositoryName } | Select-Object -First 1
if (-not $templateRepo) {
Write-LogSimple -Message "Template repository '$TemplateRepositoryName' not found. Creating empty repository and importing cache if available." -Type "WARNING"
}
$newRepo = New-RDMVault -Name $NewRepositoryName -ErrorAction Stop -IsAllowedOffline $true -VaultContentType "Everything" -SetRepository
if (-not $newRepo) {
$newRepo = Get-RDMRepository -ErrorAction Stop | Where-Object { $_.Name -eq $NewRepositoryName } | Select-Object -First 1
}
if (-not $newRepo) { throw "Repository '$NewRepositoryName' could not be created or resolved." }
Set-RDMCurrentRepository -Repository $newRepo -ErrorAction Stop
if ($TemplateExportFile -and (Test-Path $TemplateExportFile)) {
Write-LogSimple -Message "Importing template cache '$TemplateExportFile'." -Type "INFO"
Import-RDMSession -Path $TemplateExportFile -Set -ErrorAction Stop `
-ForcePromptAnswer ([System.Windows.Forms.DialogResult]::Yes) -DuplicateAction "Overwrite" | Out-Null
} else {
Write-LogSimple -Message "No template cache provided. Run single export/import flow if needed." -Type "WARNING"
}
Grant-RepositoryRoles -Repository $newRepo -RoleNames $AllowedRoles
Write-LogSimple -Message "Template applied to '$NewRepositoryName'." -Type "INFO"
} catch {
Write-LogSimple -Message "Error while cloning template: $($_.Exception.Message)" -Type "ERROR"
$existingRepo = Get-RDMRepository -ErrorAction SilentlyContinue | Where-Object { $_.Name -eq $NewRepositoryName } | Select-Object -First 1
if (-not $existingRepo) {
New-RDMVault -Name $NewRepositoryName -ErrorAction Stop -IsAllowedOffline $true -VaultContentType "Everything" -SetRepository | Out-Null
}
throw
}
}
function Grant-RepositoryRoles {
param (
[Parameter(Mandatory = $true)] [psobject]$Repository,
[string[]]$RoleNames
)
if (-not $Repository) { throw "Repository reference missing for role assignment." }
$roles = $RoleNames | Where-Object { -not [string]::IsNullOrWhiteSpace($_) } | ForEach-Object { $_.Trim() } | Where-Object { $_ }
if (-not $roles -or $roles.Count -eq 0) {
Write-LogSimple -Message "No repository roles configured; skipping role assignment." -Type "INFO"
return
}
try {
$addAccessCmd = Get-Command Add-RDMRoleRepositoryAccess -ErrorAction SilentlyContinue
if (-not $addAccessCmd) { throw "Add-RDMRoleRepositoryAccess command not available to assign roles." }
Set-RDMCurrentRepository -Repository $Repository -ErrorAction SilentlyContinue | Out-Null
Write-LogSimple -Message ("Assigning roles to repository '{0}' (ID: {1}; Type: {2})" -f $Repository.Name, $Repository.ID, $Repository.GetType().FullName) -Type "DEBUG"
$resolvedRoles = New-Object System.Collections.Generic.List[object]
foreach ($roleName in $roles) {
$roleObj = $null
Write-LogSimple -Message ("Resolving role '{0}'..." -f $roleName) -Type "DEBUG"
try {
if (Get-Command Get-RDMRole -ErrorAction SilentlyContinue) {
$roleObj = Get-RDMRole -Name $roleName -ErrorAction Stop | Select-Object -First 1
}
} catch { $roleObj = $null }
if (-not $roleObj) {
$available = @()
try { $available = (Get-RDMRole -ErrorAction SilentlyContinue | Select-Object -ExpandProperty Name) } catch { }
Write-LogSimple -Message ("Role '{0}' not found. Available roles: {1}" -f $roleName, ($available -join ", ")) -Type "ERROR"
throw "Role '$roleName' not found; cannot grant repository access."
}
Add-RDMRoleRepositoryAccess -Repository $Repository -Role $roleObj -ForcePromptAnswer ([System.Windows.Forms.DialogResult]::Yes) -ErrorAction Stop | Out-Null
$resolvedRoles.Add($roleObj.Name) | Out-Null
Write-LogSimple -Message ("Role '{0}' granted repository access." -f $roleObj.Name) -Type "DEBUG"
}
Write-LogSimple -Message ("Roles granted to repository '{0}': {1}" -f $Repository.Name, ($resolvedRoles -join ", ")) -Type "INFO"
} catch {
Write-LogSimple -Message ("Failed to assign repository roles: {0}" -f $_.Exception.Message) -Type "ERROR"
throw
}
}