Om de gebruikerservaring van deze site te verbeteren gebruikt deze website cookies.

Ik ga akkoord

juli 06, 2017

How to automate the creation of MicroStrategy users

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.

Automate MicroStrategy user creation

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.

Automate MicroStrategy user creation

 


Getting the users from the retrieved user groups


From all groups retrieved, you still have to get the users.

Automate MicroStrategy user creation

This output should be saved in a CSV-file. You will have to use this later to create the new users.

Automate MicroStrategy user creation

 

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:

Automate MicroStrategy user creation

In the next step, you loop through all the users remaining and you create variables for each property needed.
Automate MicroStrategy user creation

After this, you will need to create several Command Manager statements, I used 3:

  1.  Create user
    $output2 += echo $("CREATE USER `"" + $create.Username + "`" FULLNAME `"" + $create.DisplayName + "`" NTLINK `"\\" + $create.SamAccountName + "`" PASSWORD `"password`" ALLOWCHANGEPWD FALSE PASSWORDEXP NEVER IN GROUP `"MAINGROUP`";")`n
  2. Add address to user
    $output2 += echo $("ADD ADDRESS `"" + $create.DisplayName + "`" PHYSICALADDRESS `"" + $create.EmailAddress + "`" DELIVERYTYPE EMAIL DEVICE `"Generic Email`" TO USER `"" + $create.Username + "`";")`n
  3. 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.

Automate MicroStrategy user creation

 

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.

$output2 += echo $("ADD ADDRESS `"" + $create.DisplayName + "`" PHYSICALADDRESS `"" + $create.EmailAddress + "`" DELIVERYTYPE EMAIL DEVICE `"Generic Email`" TO USER `"" + $create.Username + "`";")`n


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
'@

Invoke-Expression -Command:$command

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:

Scheduling PowerShell scirpt

 

After naming the Task, move to the Triggers tab, select New

Scheduling PowerShell scirpt

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:

Scheduling PowerShell scirpt

 

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.

Meeusen Jorn

Meeusen Jorn

BI Consultant

Obstacles are those frightful things you see when you take your eyes off your goal

We are Agiliz

Agiliz is the preferred partner in MicroStrategy consultancy. All our consultants are certified within every aspect of the leading enterprise Business Intelligence platform. We take great pride in building the best possible BI solutions for the most demanding customers.

Start the discussion