creating a new DS entry from an existing entry using the new Devolutions.Server module
Looking at the module and the cmdlets it is not obvious to me how best to create a new DS entry by 'cloning' an existing entry. The RDM module had a concept of using a template to create a new session.
I would like all the settings to be maintained in the 'template' entry (can just be a normal entry) and then clone it with a new name and placed in a different group.
Any suggestions?
Thanks
Ed
Hello Ed,
This forum thread has a few examples that show what you are trying to accomplish: https://forum.devolutions.net/topics/37471/dvls-module-creating-ssh-tunnel
The following should get you started:
$oldEntry = (Get-DSEntry -EntryId '142c0872-5ab6-440b-bc0e-d624bd84a771').Body.data
$NewEntry = $oldEntry.PSObject.Copy() #Deep copy
#Those properties need to be removed in order to create a new entry
$NewEntry.PSObject.Properties.Remove('id')
$NewEntry.PSObject.Properties.Remove('metaInformation')
$NewEntry.PSObject.Properties.Remove('resolvedInheritedPermissions')
$NewEntry.PSObject.Properties.Remove('resolvedTimeBasedUsageSettings')
#new properties, for example the name and username
$NewEntry.name = 'newEntry'
$NewEntry.userName = 'newUsername'
$NewEntryRes = New-DSEntryBase (ConvertTo-Json $NewEntry)
Best regards,
Richard Boisvert
Thanks! That worked to create a new entry (with a slight change to line 2 - substituted variable name $SSHTunnelEntry with $oldEntry which was probably just a copy/paste issue).
Is this worth creating a new sample script in the Samples directory for this called CopyDSEntry.ps1 or CloneDSEntry.ps1 or something like that?
I could do a PR for this but seems probably overkill for that.
Thanks again. I will attempt to implement using this method.
Ed
Hello Ed,
Glad it helped! And you are correct, it was a copy/paste error, I have fixed it in the post above.
I will add it to our samples, thanks for the suggestion.
Best regards,
Richard Boisvert
Hello Ed,
The sample is now available on GitHub as well: https://github.com/Devolutions/devolutions-server/blob/main/Powershell%20Module/Samples/CloneDSEntry.ps1
Let us know if you would like to see anything else there!
Best regards,
Richard Boisvert