Cimitra Active Directory Find And Move A Computer Recipe
Instructions for making a group of Cimitra Apps to easily allow computer objects in Active Directory to be moved to a new Active Directory Organizational Unit.
Prerequisites
Deploy the Cimitra Agent on a Windows box that has access to your Active Directory system. It might be an Active Directory Domain Controller, or any other box that has access to your Active Directory system from a PowerShell terminal.
The Cimitra Active Directory Integration scripts depend upon Microsoft’s Remote Server Administration Tools (RSAT) for Windows operating systems. These tools are automatically installed on an Active Directory Domain Controller. If you are deploying these scripts on a Windows Computer that is not an Active Directory Domain Controller, then you must install RSAT.
IMPORTANT NOTE: In order to run PowerShell scripts you must assure that you have configured PowerShell to run the scripts in the directory that you have placed the scripts. In this documentation, the scripts are going to be placed in the directory: c:\cimitra\scripts\ad . Make sure you have taken the steps explained in the Windows Agent Manual Install & Post Installation Steps documentation. Specifically you want to follow the sections called “ENABLE PS SCRIPTS“. The directory that you want to focus on enabling PowerShell scripts to run in is: c:\cimitra\scripts\ad , or wherever you intend to place the PowerShell scripts that you download from the GitHub site as explained in the next section titled Download Scripts.
Download Scripts
Download the following three scripts to the Windows Computer where you have deployed the Cimitra Agent:
1. List All Computers Script [CLICK HERE]
2. Search For a Computer Script [CLICK HERE]
3. Move Computer Script [CLICK HERE]
NOTE: If you do not have a GitHub account, just view the script you want a copy of and copy it to the Windows clipboard and then paste it into a file and give it a file name similar to it’s name on GitHub.
Place the three scripts in common directory on the Windows Computer where the Cimitra Agent is deployed. In our example, we put these scripts in the directory c:\cimitra\scripts\ad
Folder Configuration
The Cimitra Apps explained in this recipe are all related to moving a computer object in Active Directory. They should all be grouped in a folder of some sort. In our example we will create a folder called “Move Computers“.
Choose an Admin-level user who will own the Cimitra Apps you are going to create. Log in as the Admin-level user and follow these steps to create a Cimitra Folder.
1. Select “Create | Folder“
2. Name the folder: MOVE COMPUTERS
3. Share the Cimitra Folder with those people who you want to have access to the Cimitra Apps you will be creating in the next few steps.
List All Computers Cimitra App
The first Cimitra App we will define is called “LIST COMPUTERS” and it will be connected to the PowerShell script you downloaded in step “2. Download Scripts” called:
ListComputersDistinguisedNames.ps1
The only command line parameter for this script is:
-ShowErrors <Optional>
This script searches the entire Active Directory tree looking for computer objects and then displaying these objects.
You may or may not want to use this script, and it isn’t entirely necessary. But it is an option that you may want.
1. In Cimitra Web Administration, make sure to be in the “MOVE COMPUTERS” Cimitra Folder.
2. Select “Create | App“
3. Fill in the fields as follows:
Name: LIST ALL COMPUTERS
Platform: Windows
Agent: <The Cimitra Agent you deployed to this Windows computer>
Interpreter: c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Script/Command: c:\cimitra\scripts\ad\ListComputersDistinguisedNames.ps1
Switches: -ShowErrors
Save the Cimitra App and run it. You should see something similar to the screenshot below.
Find A Computer Cimitra App
The second Cimitra App we will define is called “FIND A COMPUTER” and it will be connected to the PowerShell script you downloaded in step “2. Download Scripts” called:
SearchForComputer.ps1
The command line parameters for this script are:
-ShowErrors <Optional>
-ComputerNameIn <The Computer Name>
This script searches the entire Active Directory tree looking for the computer object that the end-user specifies.
You may or may not want to use this script, and it isn’t entirely necessary. But it is an option that you may want.
1. In Cimitra Web Administration, make sure to be in the “MOVE COMPUTERS” Cimitra Folder.
2. Select “Create | App“
3. Fill in the fields as follows:
Name: FIND A COMPUTER
Platform: Windows
Agent: <The Cimitra Agent you deployed to this Windows computer>
Interpreter: c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Script/Command: c:\cimitra\scripts\ad\SearchForComputer.ps1
Switches: -ShowErrors
4. Select +Add Switch
5. Fill in the fields under the Switch as follows:
Label: COMPUTER NAME
Switch: -ComputerNameIn
Validating Regex:
In this example, we will allow numbers, letters, dashes, and underscores. So the Validating Regex will be:
/^[0-9A-Za-z\_\+\-\=]+$/
as shown in the screenshot below.
Example: WIN-COMPUTER-ONE
Save the Cimitra App and run it. You should see something similar to the screenshots below.
Find And Move A Computer Cimitra App
The third Cimitra App we will define is called “Find And Move Computer” and it will be connected to the PowerShell script you downloaded in step “2. Download Scripts” called:
FindAndMoveComputer.ps1
The command-line parameters for this script are:
-ShowErrors
-ComputerNameIn
-NewContextIn
This script issues a MoveADObject command to Active Directory to move the Computer that the user specifies to a new Active Directory Context.
This Cimitra App is meant to showcase the multiple-choice feature in Cimitra called a: Drop Down List
1. In Cimitra Web Administration, make sure to be in the “MOVE COMPUTERS” Cimitra Folder.
2. Select “Create | App“
3. Fill in the fields as follows:
Name: FIND AND MOVE A COMPUTER
Platform: Windows
Agent:
Interpreter: c:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Script/Command: c:\cimitra\scripts\ad\FindAndMoveComputer.ps1
Switches: -ShowErrors
4. Select +Add Switch
5. Fill in the fields under the Switch as follows:
Label: COMPUTER NAME
Switch: -ComputerNameIn
Validating Regex:
In this example, we will allow numbers, letters, dashes, and underscores. So the Validating Regex will be:
/^[0-9A-Za-z\_\+\-\=]+$/
as shown in the screenshot below.
Example: WIN-COMPUTER-ONE
6. Select +Add Switch
7. Fill in the fields of the Switch as follows:
Label: NEW CONTEXT
Switch: -NewContextIn
Validation Type: Drop Down List
8. Select +Add Item
9. Fill in the fields of the Item as follows:
Label:
(Example Label) STUDENTS
Switch/Command/Script: ‘OU=STUDENTS, OU= . . .’
So in our example we used the following:
“OU=STUDENTS,OU=DEMOCOMPUTERS,DC=cimitrademo,DC=local”
NOTE: Make sure to put the single quote marks at the beginning and end of the context as shown above.
10. For as many OUs you want to define, perform steps 8 & 9 for each OU.
The Cimitra App’s Admin Configuration screen should look similar to the screenshots below.
Save the Cimitra App and run it. You should see something similar to the screenshots below.