Partager via


Azure AD user management scripts

Recently I had an opportunity to create couple of scripts for a customer for Azure AD management linked with o365 . We have all these resources available in our documentation, albeit scattered at different places . Few scripts were also tweaked to meet certain specific requirements. I am sharing the same here for the benefit of the larger community

Import modules:

The first step is to import all modules required for O365 management. We have detailed steps available  in this TechNet article :https://technet.microsoft.com/en-us/library/dn568015.aspx

I have put all the commands together in this script importmodules_o365

Edit the script as appropriate before execution to provide your environment specific parameters like domain name. I have provided comments regarding that wherever required.

Once you have imported all the required PowerShell modules, some common AD management tasks can be done using the scripts available in this zip file : Management_Scripts

View and export list of users with different user roles

Use the  script exportrole.ps1 to get details of user roles. By default the script will pull out list of users with the role 'Company Administrator' to a file named username.csv . You can modify the rolename to get the corresponding users with that role assigned. List of roles are also given at the end of the script.

Password  expiry date of users

The script passwordexpirydates.ps1 will extract this info to a csv titled passwordexpirydates.csv

Last password change date of users

Execute the script Passwordchangedate.ps1 will extract this info to a csv titled userpasswordchangedate.csv

List of blocked users

You can use the  script Blockedusers.ps1 to get information on blocked users if any