If you want to have users created automatically from a certain list, there are several ways to achieve it. I chose to use Windows PowerShell and have it scheduled with Windows Task Manager.
What you need:
• Basic to average knowledge of Windows PowerShell
• Basic knowledge of MicroStrategy Command Manager
• Admin rights to the server your MicroStrategy environment is running on
• Access to Windows Task Manager
In my example, the list of users is stored in Active Directory. But with a few changes, you can use this for any other list possible.
Getting the correct user groups in Active Directory
First of all, you need to have a list of all Active Directory groups and after that, you need to define whether the group is a domain.
You will most probably not need the entire Active Directory. So you will need a filter that will get you the groups where your users are stored.
Getting the users from the retrieved user groups
From all groups retrieved, you still have to get the users.
This output should be saved in a CSV-file. You will have to use this later to create the new users.
Making the CREATE statement for the correct users
In the same folder (in this case, it is d:\MicroStrategyShared\Powershell\) you have to create an empty CSV with the name ‘output_yesterday.csv’. Then you create the next variables:
In the next step, you loop through all the users remaining and you create variables for each property needed.
After this, you will need to create several Command Manager statements, I used 3:
- Create user
$output2 += echo $(“CREATE USER `”” + $create.Username + “`” FULLNAME `”” + $create.DisplayName + “`” NTLINK `”\\” + $create.SamAccountName + “`” PASSWORD `”password`” ALLOWCHANGEPWD FALSE PASSWORDEXP NEVER IN GROUP `”MAINGROUP`”;”)`n
- Add address to user
$output2 += echo $(“ADD ADDRESS `”” + $create.DisplayName + “`” PHYSICALADDRESS `”” + $create.EmailAddress + “`” DELIVERYTYPE EMAIL DEVICE `”Generic Email`” TO USER `”” + $create.Username + “`”;”)`n
- Add the user to extra groups
$output2 += echo $(“ADD USER `”” + $create.Username + “`” TO GROUP `”Basic Users`”,`”MicroStrategy Web Professional`”, `”” + $create.DivName + “_” + $create.DivName + “`”;”)`n
Just to sure, add a line at the bottom: $create = $null. Then you close the loop with a ‘}’
Executing the script
The output of the loop is stored in an SCP-file which will, later on, be used to create the user in MicroStrategy.
Before the execution of the report you need to make some changes to the CSV files with the user outputs. The output_yesterday.csv file will be deleted and the output.csv file will be renamed to output_yesterday.csv. The next time you run the script, the new output.csv will be compared with the script that was renamed the last time you ran it.
To execute the script, you have to build the command first. After that you can execute the script.
$command = @’
cmd.exe /C cmdmgr -n “PROJECT” -u Administrator -f
D:\MicroStrategyShared\Powershell\update.scp -p p@ssW0rd
Scheduling the PowerShell script
To schedule the PowerShell script, I use Windows Task Manager on Windows Server.
Open Task Manager and click ‘Create Task’ in the right column. Following window pops up:
After naming the Task, move to the Triggers tab, select New
When you reach this point, your automatic user creation flow should be ready. It should run whenever you scheduled it.
Move to the Actions tab and select New:
In the Add arguments box, this is what it should state:
-ExecutionPolicy Bypass D:\MicroStrategyShared\Powershell\[CreateUserScript].ps1
Your automatic user creation script is now scheduled.
Our experts are happy to help
You’d like to know information, or more tips & tricks on how to work with MicroStrategy?
Contact us to book an appointment with an expert.