Custom RDM Powershell for multiple entries.

Resolved

Custom RDM Powershell for multiple entries.

avatar

Good morning, folks.

I have a plethora amount of entries that I need to make the same change to. Only problem is, I can't figure out how to select just those specific entries.

I am trying to add a setting to Customfield2 as follows for example:

$connection.MetaInformation.CustomField2 = "THIS IS MY ENTRY"
$RDM.Save();

How can I get that option on 37 different entries at the same time?

Thanks!

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free

All Comments (9)

avatar

Or is this maybe not possible to do?

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free

avatar

Hello Charles,

Could you try this?

$sessions = Get-RDMSession | Where-Object {$_.ConnectionType -eq "RDPConfigured"}
foreach ($session in $sessions){
    $session.MetaInformation.CustomField2Value = "This is my entry"
    Write-Host $session.MetaInformation.CustomField2Value
    Set-RDMSession $session -Refresh
    Write-Host $session.Name
}
update-rdmui

Best regards,

Patrick Ouimet

avatar

Good morning Patrick.

That command I believe will apply the "CustomField2Value" to all RDPConfigured entries, correct?

I need a way to just specify specific entries needed.

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free

avatar

Hello Chuck,

Yes, this is correct.
This value, however, could be replaced with anything else to get your entries.

Could you tell me if there is something that can relate all of them together?
It could be an IP address - username - or even a folder.

Best regards,

Patrick Ouimet

avatar

Unfortunately, no.

I have to manually go through and update all the entries with the IP address in "Alternate Host", since RDM does not pull in the IP address for any kind of A/D Sync (unfortunately).

There's 2 in one folder, 21 in another folder, 14 in another folder, etc. But those folders also have other sessions in them as well, that can't be updated with this information.

Only thing that relates them together is the CustomField2Value I am trying to add.

Too bad there isn't a way to read in entries from a csv file or something. Just the simple session names.

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free

avatar

Hello Chuck,

We have a customer that shared a script to exactly to this.
I changed it to fit the custom field value that you need.

$csvData = Import-Csv -Path '<Your path>'


# Fetch all RDM data sources
$dataSourceList = Get-RDMDataSource


# Prepare a list to hold the results
$results = @()


# Iterate through each row in the CSV
foreach ($row in $csvData) {
    $deviceName = $row.Device_Name
    $customfield2 = $row.CustomField2Value
    $oldcustomfield2 = $null
    $updateResult = "Entry Not Found"
    $updatedDataSource = $null
    Write-host "Connecting to $deviceName"
    foreach ($dataSource in $dataSourceList) {
        Set-RDMCurrentDataSource -DataSource $dataSource
        $rdmSessions = Get-RDMSession -IncludeSubFolders | Where-Object { $_.Name -eq $deviceName }


        if ($rdmSessions) {
            foreach ($session in $rdmSessions) {
                $oldcustomfield2 = $session.MetaInformation.CustomField2Value
                if ($oldcustomfield2 -ne $customfield2) {
                    $session.MetaInformation.CustomField2Value = $customfield2
                    Set-RDMSession -Session $session
                    update-rdmui
                    $updateResult = "Success"
                    $updatedDataSource = $dataSource.Name
                    
                    Write-Host "Updated entry for device '$deviceName' in data source '$($dataSource.Name)'"
                } else {
                    $updateResult = "No Change Needed"
                }


                $results += [PSCustomObject]@{
                    Device_Name = $deviceName
                    Old_Custom_Field_2 = $oldcustomfield2
                    Company = $company                    
                    New_IP_address = if($updateResult -eq "Success") { $customfield2 } else { $null }
                    Update_Result = $updateResult
                    Updated_DataSource = $updatedDataSource
                }
            }
        }
    }
}


# Export the results to a CSV file named with the current date
$timestamp = Get-Date -Format "yyyyMMddHHmmss"
$outputFileName = "update_results_$timestamp.csv"
$results | Export-Csv -Path $outputFileName -NoTypeInformation


Write-Host "Results have been exported to $outputFileName"

Note that this is for the main vault and multiple databases only.
You can change this for all the vaults instead.

Best regards,

Patrick Ouimet

avatar

Awesome! Thank you, sir. And thank you to that customer.

I will modify this for my needs and see how it works.

Have a great afternoon!

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free

avatar

Hello Chuck,

This could also be a great alternative regarding your other forum for the CSV and AD synchronizer.

Best regards,

Patrick Ouimet

avatar
Hello Chuck,

This could also be a great alternative regarding your other forum for the CSV and AD synchronizer.

Best regards,


I was just thinking about that yesterday to use until it's fixed in RDM.

Just need to figure out the best way to do it on that script. :-)

--- Chuck
Overgaard, AZ (-7 MST / Zulu Year-Round)
RDM Version: 2026.3.2.0 64-Bit - Free