Hello,
Attached to this post, is the PowerShell file RDM-PS-Functions.ps1 that contains functions to help for the migration of information from a data source to another one.
Remote Desktop Manager version 12.x or higher must be installed on the computer where these functions will be used.
To be able to use these functions in a PowerShell script, add the following line at the beginning of your script. Please adapt the path where the RDM-PS-Functions.ps1 is located on the computer.Import-Module "C:\Tools\RDM-PS-Functions.ps1"Following this post, you will find examples of each function available in this file.
Here is an example of a script that use these functions to migrate the information from a data source to another one.
Import-Module "C:\Tools\RDM-PS-Functions.ps1" # Select the main data source Select-DS # Export the Data Source using the default values of each functions. $SecGrp = Export-SecGrpToFile $Roles = Export-RolesToFile $Sessions = Export-SessionsToFile $SecGrpXML = $SecGrp[0] $SecGrpTXT = $SecGrp[1] # Select the destination data source Select-DS # Clean the content of the destination data source Clear-Sessions -verbose Clear-Roles -verbose Clear-SecGrp -verbose # Import the data into the destination data source. Import-Sessions $Sessions Import-SecGrp $SecGrpXML $SecGrpTXT Import-Roles $Roles Write-Host "Done!!!" Write-Host
Best regards,
Érica Poirier
RDM-PS-Functions.ps1
Function : Select-DS
Description : Displays a dialog to select a data source from the list of data sources configured for the local RDM.
Parameter :
(optional) [string]inputMSG - The title of the dialog.
Return :
[System.Object]$currentDS - The selected data source.
Example :$currentDS = Select-DS "Select the Data Source to export"
Érica Poirier
Function : Export-SecGrpToFile
Description : Export the Security Groups and the name of the Group Folders that are protected by these Security Groups.
Parameter :
(optional) [string]SecGrpXML - File name that contains the Security Groups.
(optional) [string]SecGrpTXT - File name that contains the Group Folders associated to Security Groups.
Return : Array of [string]
- File name that contains the Security Groups.
- File name that contains the Group Folders associated to Security Groups.
Example :$fileNames = Export-SecGrpToFile "c:\temp\SecGrp.xml" "c:\temp\Groups.txt"
Érica Poirier
Function : Export-RolesToFile
Description : Export the Roles into a file.
Parameter :
(optional) [string]RolesXML - File name that contains the Roles.
Return :
[string] - File name that contains the Roles.
Example :$rolesFile = Export-RolesToFile "c:\temp\RolesXML.xml"
Érica Poirier
Function : Export-SessionsToFile
Description : Export the Sessions into a file.
Parameter :
(optional) [string]SessionXML - File name that contains the Sessions.
Return :
[string] - Path and file name that contains the Sessions.
Example :$sessionsFile = Export-SessionsToFile "c:\temp\ExportSessions.rdm"
Érica Poirier
Function : Clear-Sessions
Description : Delete all Sessions in the current data source.
Example :Clear-Sessions
Érica Poirier
Function : Clear-Roles
Description : Delete all Roles in the current data source.
Example :Clear-Roles
Érica Poirier
Function : Clear-SecGrp
Description : Delete all Security Groups in the current data source.
Example :Clear-SecGrp
Érica Poirier
Function : Import-Sessions
Description : Import the sessions from a file in the current data source.
Parameter :
(optional) [string]SessionXML - File name that contains the Sessions.
Return :
Example :Import-Sessions "c:\temp\ExportSessions.rdm"
Érica Poirier
Function : Import-SecGrp
Description : Import the Security Groups from a file in the current data source.
Parameter :
(optional) [string]SecGrpXML - File name that contains the Security Groups.
(optional) [string]SecGrpTXT - File name that contains the Group Folders associated to Security Groups.
Return :
Example :Import-SecGrp "c:\temp\SecGrpXML.xml" "c:\temp\Groups.txt"
Érica Poirier
Function : Import-Roles
Description : Import the Roles from a file in the current data source.
Parameter :
(optional) [string]RolesXML - File name that contains the Roles.
Return :
Example :Import-Roles "c:\temp\RolesXML.xml"
Érica Poirier
Function : Set-RoleToUser
Description : Assign a User to a Role.
Parameter :
(mandatory) RoleName - Name of the Role.
(mandatory) UserName - Name of the User.
Return :
Example :Set-RoleToUser "Operators" "John"
Érica Poirier
Function : Remove-SyncSession
Description : Delete all sessions created from a synchronizer (AD, CSV).
Example :Remove-SyncSession
Érica Poirier
Function : Export-RoleMembersToFile
Description : Export role membership for each user account into a file.
Parameter :
(optional) [string]RoleMembers - File name that contains the Role's membership.
Return :
[string] - File name that contains the Role's membership.
Example:$RoleMembers = Export-RoleMembersToFile "c:\temp\RoleMembers.csv"
Érica Poirier
Function : Export-UsersToFile
Description : Export the user accounts into a file.
Parameter :
(optional) [string]UsersXML - File name contains the user accounts.
Return :
[string] - File name that contains the user accounts.
Example:$Users = Export-UsersToFile "c:\temp\ExportUsers.xml
Érica Poirier
Function : Import-Users
Description : Import the user accounts from a file in the current data source.
Parameter :
(optional) [string]UsersXML - File name contains the user accounts.
Return :
Example:Import-Users "c:\temp\ExportUsers.xml"
Érica Poirier
Function : Import-RoleMembers
Description : Import role membership for each user account from a file in the current data source.
Parameter :
(optional) [string]RoleMembers - File name that contains the Role's membership.
Return :
Example:Import-RoleMembers "c:\temp\RoleMembers.csv"
Érica Poirier