Forum / Remote Desktop Manager - PowerShell Repository

Mass Import from CSV File

  • Create an Issue
  • Cancel

Hi All

(NOTE : Text and Attachment updated since initial post)

Not sure how many people are trying to use PowerShell to load entries into RDM, but I certainly had the need, so I thought I would share the final script that I used on Friday to insert more than 1,600 entries into our RDM SQL DB. The attached script shows a number of techniques that might be of interest to people, including how to create a credential entry, then create another (RDP) entry that uses that credential entry, also how to set RDP Gateway settings, and how to store both plain text and encrypted passwords into a credential entry. I publish this in the hope that it saves someone a few minutes one day.

The main things I couldn't get working where : 1) Setting the Security Group (I tried using both the group name, and also the GUID of group entry - no luck! - I think because the Set-RDM-Property cmdlet converts the input paramter to type String? Not sure...I just gave up and just did a Batch Edit after the records where in RDM instead) UPDATE : Now working - see post below - Thanks, Stefane, 2) Setting the icon (again, I set these using Batch Edit afterwards), and 3) Setting detailed fields inside a DataEntry type entry.

Regards
Des
edited by ceo_rdm on 9/17/2013

RDMImport_v2.ps1
Clock7 yrs

Thank you for sharing.

I will look at the issue with the team here, we'll keep you posted.



Maurice Côté

signaturesignature

Clock7 yrs

Des,

Amazing script, thank you for sharing.

For next time, when setting a GUID property you must cast the string to [GUID] for it to work:

$g = [GUID]"cc0f1a75-aa7f-4d6a-bfab-82bdb01010c0"
set-rdm-property -ID -$id -Property "SecurityGroup" -Value $g -NoRefresh

3) Setting detailed fields inside a DataEntry type entry.

What field and entry type did you want to set?

Stefane Lavergne

signaturesignature

Clock7 yrs

Stefane
Thanks for the tip re: SecurityGroup. I still don't fully understand why this didn't work :
Set-RDM-Property -ID $thisID -Property SecurityGroup -Value [GUID]"80cbfce3-5315-4b02-ab65-eaef7afe8a04" -NoRefresh

but I'm very happy with the two-line workaround you've suggested - cheers!

I have ammended the attachment above accordingly.

As for 3) - I was trying to change the DataEnry type to "Other", and then set a bunch of paramter/value pairs. When I looked at the XML it appears that RDM encrypts/encodes this type of entry, so it wasn't practical to do for me. In the end, it wasn't a great problem for me, so don't spend any more time on it.

Kind Regards
Des

Clock7 yrs

Des,

Set-RDM-Property -ID $thisID -Property SecurityGroup -Value [GUID]"80cbfce3-5315-4b02-ab65-eaef7afe8a04" -NoRefresh

No clue why if doesn't work like that, I had the same issue. I will try to investigate when(aka if :-)) I have time.

As for #3, it would make an interesting forum "PowerShell how to" post. Thanks for the info.

Stefane Lavergne

signaturesignature

Clock7 yrs

Des Bylund wrote:

Hi All

(NOTE : Text and Attachment updated since initial post)

Not sure how many people are trying to use PowerShell to load entries into RDM, but I certainly had the need, so I thought I would share the final script that I used on Friday to insert more than 1,600 entries into our RDM SQL DB. The attached script shows a number of techniques that might be of interest to people, including how to create a credential entry, then create another (RDP) entry that uses that credential entry, also how to set RDP Gateway settings, and how to store both plain text and encrypted passwords into a credential entry. I publish this in the hope that it saves someone a few minutes one day.

The main things I couldn't get working where : 1) Setting the Security Group (I tried using both the group name, and also the GUID of group entry - no luck! - I think because the Set-RDM-Property cmdlet converts the input paramter to type String? Not sure...I just gave up and just did a Batch Edit after the records where in RDM instead) UPDATE : Now working - see post below - Thanks, Stefane, 2) Setting the icon (again, I set these using Batch Edit afterwards), and 3) Setting detailed fields inside a DataEntry type entry.

Regards
Des
edited by ceo_rdm on 9/17/2013

Des,

Yes, this script is awesome! I've been looking for something along these lines. However, I have different needs. First of all, can you provide a sample .csv file that this script would work with? I'm assuming you have to specify file location for the .csv file in the script? We create sessions that are used for remote connections to training equipment for students. I would like to be able to package multiple types of connections and assemble it quickly using a script or setting it up in a spreadsheet that can be exported to .csv format and then have this script create the connections. This will hopefully make it easier for developers to create these sessions faster so they can be redistributed.

We use RDP, PuTTY, Web Browser, and text sessions mostly, and occasionally documentation sessions as well. Any help would be appreciated. Thanks.

Clock6 yrs

Tom

Good to see a fellow RDM user getting some value from my script - that's why I posted it!

I didn't originally include a sample .csv input file, since I thought the .csv format was so universal that I assumed people would be able to read the code and figure it out. Here are the first two lines of my .csv file :

SchoolNumber,School Name,Salutation,Preferred Name,Surname,Title,StreetAddress 1,StreetSuburb,StreetState,StreetPost Code,Phone Number,Fax Number,Email Address,Web Site,SINA-U,SINA-P
9999,Aquinas College,Mr,Mark,Smith,Principal,58 Mount Henry Road,SALTER POINT,WA,6152,9999 9999,9999 8888,admin@aquinas.wa.edu.au,www.aquinas.wa.edu.au,aquinas,xxxxxx

The location of the file is specified on line 28. My .csv file is in the same folder as the script, so I didn't need to specify a path.

Des
edited by ceo_rdm on 12/9/2013

Clock6 yrs

Just as support: thanks for the script (i still have to analyze it, but everything that is shared deserve a thanks).

Clock6 yrs

Just wanted to say that now that I know a little bit more about powershell scripting, that I understand how the .csv file feeds into the scripts, so if this was something you posted today, I probably wouldn't have asked for the .csv file. :-)

Clock5 yrs