Example 1 - Creating a home directory if it does not exist yet and
update the AD
In the following example, we will create a home directory for those
users in the organizational unit "Marketing" who do not already
have one. For this example we assume that you have a CSV file with users
who belong to the OU "Marketing".
1. Drag the Set variable action
to the Script Actions window.
Set the value for the variable %OU%
to "Marketing"
2. Drag the Set variable action
to the Script Actions window.
Set the value of the variable %ShareName%
to "<MyShare>" where <MyShare> corresponds
with the name of the share where the home folders should be created (e.g.
"Users").
3. Drag the Set variable action
to the Script Actions window.
Set the value of the variable %Domain%
to the name of the domain.
4. Drag the Get user action
to the ScriptActions
window. Set the Domain property
to %Domain% and the Username
property to %UserName%
5. Drag the Get attribute action
to the Script Actions window.
Set the value of the LDAP attribute display name to "homeDirectory".
This is the attribute representing the home directory for the account.
Set the output variable to %HomeDirectoryValue%.
Set the Error if empty property
to "No".
Next, we need to evaluate if a home folder already exists. If not, we
will create a homefolder with the full name of the user. If it does exist,
the script will do nothing. To achieve this, we will use the If-Then-Else.
action.
6. Drag the If-Then-Else action
to the Script Actions window and
doubleclick on "If...Then Goto label:" The Properties
dialog box will appear:
In the IF section of this dialog
box, you can specify your evaluation criteria.
In the Then section you specify
which action should be executed if the condition is TRUE
In the Else section you specify
which action (if any) needs to be executed if the condition is FALSE
7. Click the Edit button. The
Setup Condition Criteria dialog
box will appear:
8. Click the Add button to add
a criterion. The Setup criterion dialog
box will appear. In this dialog box we need to specify if a home directory
already exists. In our case, the home folder is stored in the variable
%HomeDirectoryValue%. If it does not exist, a home folder should be created.
9. Select the variable %HomeDirectoryValue%
in the list of variable names. In the Equation
operator section, select the operator "has no value or does
not exist" .
10. Click OK. The criterion will now be added to the list of criteria.
If you have more than one criterion, you can also specify if ALL conditions
should be met, or if at least one of the listed conditions should be met.
11. Click OK again to return to the Properties
dialog box. In the Then section,
enter the label of the action which needs to be executed if the condition
is met. For this example, we will use the script label "Create Home
Directory". If the condition is not met, no action is required, so
we can leave the Else section
as is. Click OK to return to the Action
window..
12. Drag the Create directory action
to the Script Actions window and
set the following property values:
Computer - Specify the name
of the computer on which the directory must be created
Parent Path - The path of the
parent directory on the specified computer. For our example, you need
to set this to %ShareName%
Directory name - For
this example, we are assuming that the CSV file you are using contains
a column with the full name of the user which has been set to %FullName%.
Use this variable %FullName% as the directory name.
Share Name -
The name of the share that is used to create a share on the new directory.
For the purpose of this example, we will assume that it is equal to the
variable %ShareName%.
In the last step, we will set the
home folder attribute to the current value.
13. Drag the Edit
User (AD) action to the Scripts Action
window and set the following property values:
Home directory
- The path of the home directory of the user account. For our example,
this can be set to \\%ShareName%\%FullName%.
Home directory drive -
The drive letter assigned to the user's home directory for logon purposes.
For this example, we are setting this value to "C:\" (in reality
this will be a network drive).
Once you have completed these steps,
you are ready to run it in test mode.