Creating Users and Groups with Microsoft Graph PowerShell (Minecraft Server Admin AZ-104 Quest)

I’m diving into identity management with Microsoft Graph PowerShell. Managing users and groups in Azure is like organizing your server’s ranks in Minecraft.

If you’re prepping for the AZ-104 exam or just wanna automate identity tasks in Azure, you’re in the right place. Let’s go!

By the way, if you want to see all the code in action or fork your own version, check out my GitHub repository at https://github.com/shevonnepolastre/minecraft-azure-quests/tree/main/quests/01-identities-governance (because sharing is caring, right?).


Why Identity Matters (Minecraft Style)

Suppose you were running a Minecraft server and needed to give different permissions to builders, redstone geniuses, adventurers, and moderators. It’s all about users and groups in the Azure world, which let you automate and control access.

You know what else? Instead of point-and-clicking, you can script these tasks with Microsoft Graph PowerShell and get some serious admin power across Microsoft 365, Azure AD, and more. Let’s go!


Step 1: Install Microsoft Graph PowerShell

To begin, install the module:

Install-Module Microsoft.Graph -Scope CurrentUser

Then connect to Microsoft Graph:

Connect-MgGraph -Scopes “User.ReadWrite.All”, “Group.ReadWrite.All”

You’ll be prompted to log in and grant permission — consider it your enchanted key to the Azure Identity Kingdom.


Step 2: Create a New User

Time to spawn a new Azure user:

New-MgUser -AccountEnabled $true ` -DisplayName “Minecraft Warrior” ` -UserPrincipalName “[email protected]” ` -MailNickname “warrior” ` -PasswordProfile @{ForceChangePasswordNextSignIn=$true; Password=”StrongP@ssword123!”}

This command conjures up the “Minecraft Warrior” user with a temporary password. Think of it like handing a new player starter gear and having them personalize it on their first quest.


Step 3: Create a Group

Next, let’s create a group for your PvP Legends, fellow cloud engineers, or any band of adventurers you want to manage together:

New-MgGroup -DisplayName “Cloud Adventurers” ` -MailEnabled $false ` -MailNickname “cloudadventurers” ` -SecurityEnabled $true ` -GroupTypes @()

Boom! You’ve formed a security group named Cloud Adventurers. Use it to manage permissions at scale — kind of like giving your Minecraft clan special privileges on your server.


Step 4: Add User to Group

Let’s add our newly minted Minecraft Warrior to the Cloud Adventurers group.

First, fetch the IDs:

$user = Get-MgUser -UserId “[email protected]” $group = Get-MgGroup -Filter “DisplayName eq ‘Cloud Adventurers'”

Then, toss the user into the group:

New-MgGroupMember -GroupId $group.Id -DirectoryObjectId $user.Id

Just like assigning someone to a Minecraft faction, you’ve given them membership in a new team.


Bonus: Automate It!

All these commands can be part of a larger PowerShell script. You can loop through a CSV of usernames, integrate it with deployment pipelines, or even have it triggered automatically whenever you need new users created.


What You Learned

  • Installing and authenticating with Microsoft Graph PowerShell
  • Creating Azure AD users
  • Creating security groups
  • Adding users to groups

These are core identity management tasks you’ll need for real-world Azure roles and definitely for the AZ-104 exam.


Apply This in Real Life

Whether it’s a Minecraft server, a dev team, or your next cloud project, setting up users and groups with PowerShell can save tons of time and show off your automation chops.

In upcoming quests, we’ll explore:

  • Assigning roles and permissions
  • Automating license assignments
  • Querying groups and nested members

So stick around, subscribe to my YouTube channel for the full Minecraft Server Admin AZ-104 Quest playlist, and keep leveling up your Azure skills!


Want More?

For the complete code and any additional tweaks, make sure to visit my GitHub repository at https://github.com/shevonnepolastre/minecraft-azure-quests/tree/main/quests/01-identities-governance.

Leave a Reply

Scroll to Top