Moving multiple users between organizations can be done quickly and easily using the sample scripts provided in this article.  This script addresses the scenario where a subset of users in Organization A need to be moved to Organization B and their VM ownership does not need to follow them.



Requirements:

  • vCommander scripts (Download here)
  • PowerShell v4 installed on the vCommander application server
  • Embotics® vCommander® 6.1.7 or later
  • Embotics vCommander 2.8 REST API PowerShell libraries (Download here)
  • If not already done, create an encrypted credentials file for vCommander  using the PowerShell command: New-EncryptCredential -destFilePath C:\scripts\credential.xml

Step 1: Setting up the Script

1. Download and copy the attached "Update Org Members.zip" file to the vCommander Server.

2. Extract the Update Org Members.ps1 file to c:\scripts on the vCommander server

3. Open the script for editing

4. edit the parameters below to match your environment.  Note: you will be prompted to edit a txt file when running the script, to ensure smooth operation the $filemodify variable must be in a location the user running the script can write to.


$vCommanderServer = 'vCommander.company.com'   #< vCommander Server
$CredFile = 'C:\scripts\credential.xml'  #< vCommander Cred File
$oldorg = "Old Org Name"     #< Name of org to move users from
$neworg = "New Org Name"     #< Name of org to move users to
$filemodify = "c:\scripts\Users.txt"  #< temp txt file to create and modify


Step 2: Running the Script


1. Once all the parameters are correct you can run the script, the connection to vCommander will be initialized using the credentials file

2. a list of all users in the "Old Org" will be compiled and saved in the location specified by $filemodify, once completed you will be prompted with the dialog box below (it may be hiding behind another window)

3. Following the prompt from the dialog box, navigate to the path specified in $filemodify, DO NOT press OK at this time or all users will be moved into the "new org".

4. remove any users you DO NOT want to be moved into the "New Org" from the users.txt file


5. Save the Users.txt file

6. Press OK on the dialog box to continue the execution of the script.


Step 3: Verification


Now that the script has completed any user that was in Organization A that was left in the users.txt file will have been moved into Organization B.  

1. In the vCommander admin console navigate to Configuration > Organizations and Quotas 

2. Click on the "Old Org" and verify the users do not exist in this organization

3. Click on the "New Org" and verify the users do exist in this organization


Step 4: Considerations


As VM ownership is unaffected by this script VMs will still belong to the original organization and the user will remain the primary owner, although they will not have access to those VMs in the portal.


To address this you can use the search criteria below to multi-select and set ownership for those VMs.