Add an entry to RDM with Powershell

Add an entry to RDM with Powershell

avatar

Hello,

We use RDM on Windows, the database is MySQL.

I try to add a new entry from a PowerShell script.

I installed PowerShell on a Red Hat Enterprise Linux 8.

I added my Datasource with this command :

New-RDMDataSource -MySQL -Hostname $shost -Schema $sdbname -Name $sname -SetDatasource

$shost is a variable with my MySQL Database server.
$sdbname is a variable whicth contains the database name of RDM.
$sname is the name of DataSource i want.

After executing this New-RDMDataSource PowerShell says to me :

Access denied for user ''@'SRV-PWSH.domain.priv'

ID : 0fd4f185-2c4b-45bd-b8b3-e8b9090fc645
IsConnected : False
IsOffline : False
Name : RDMPP
Type : MySQL

I don't know how to use credentials of MySQL database.

And Get-RDMDataSource list the local Data Source i don't use + MySQL Source :

ID : 12f8bcfc-cebb-4ae3-baf9-2fe03b4ad51a
IsConnected : False
IsOffline : False
Name : Local Data Source
Type : SQLite

ID : 0fd4f185-2c4b-45bd-b8b3-e8b9090fc645
IsConnected : False
IsOffline : False
Name : RDMPP
Type : MySQL

But indeed, MySQL IsCOnnected : False

How to connect the datasource to add an entry with PowerShell after ?

Note : Database Server isn't the same than PowerShell Server, both are Red Hat Enterprise Linux.

I found some command lines on this forum but only for SQLServer.

Thanks for your help

All Comments (3)

avatar

Hello,

The local data source is created automatically the first time the PowerShell module is ran, since a data source is required in RDM. Since you have a MySQL one, it could be removed without issue:

$local = Get-RDMDataSource -Name "Local Data Source"
Remove-RDMCurrentDataSource $local


With a MySQL data source, it is unfortunately not possible to set a username you wish to use. Your PowerShell session would need to be opened as the user you wish to connect as, or you would need to add '@'SRV-PWSH.domain.priv as a user in your MySQL database.

Once this is in place, you can use the following to connect to the data source:

$ds = Get-RDMDataSource -Name "RDMPP"
Set-RDMCurrentDataSource $ds


Best regards,

Richard Boisvert

avatar

Hello

OK thanks !

I didn't remove the Local source, i can do that : true.

I see that i must do for this MySQL Connection. I think without password to access to the database ? :/

Thanks for your answer

avatar

Hello Adrien,

It should take the current context for the authentication.

Let us know if it works!

Best regards,

Richard Boisvert