Are you wondering what to do now that Azure AD, Azure AD Preview and MSOnline PowerShell modules are officially deprecated?
It’s time to upgrade to Microsoft Graph PowerShell for a seamless experience!
Simplify Your Workflow with Microsoft Graph PowerShell
With the official deprecation of Azure AD, Azure AD Preview, and MSOnline PowerShell modules Microsoft Graph PowerShell is now the preferred PowerShell module to use for interacting with Microsoft Entra ID and other Microsoft services.
So, here’s the deal: Scripts that you’ve written in Azure AD PowerShell won’t just seamlessly switch over to Microsoft Graph PowerShell. They’re like two different languages. But don’t sweat it too much – the new cmdlet names are pretty straightforward. Instead of the old ‘AzureAD’ or ‘AzureADMS’, you’ll be using ‘Mg’. For instance, if you’re used to ‘Get-AzureADUser’, now it’s ‘Get-MgUser’.
But here’s the kicker: It’s not just about memorising new names. There’s a bit more to it. We’re talking about renamed modules, tweaked parameters, and other nitty-gritty changes.
We’ve got your back though! We’ve cooked up a simple process to help you upgrade your existing scripts. It’s a two-step dance: first, you’ll need to jot down what your scripts are all about, and then it’s time to give them a makeover. Easy peasy, right?
Document your current scripts
Alright, let’s get down to it. Documentation is important! How many of you can say you feel like you’re 100% on top of your documentation? Here’s the breakdown on documenting your current scripts:
- Purpose: What’s the script all about? What’s its main gig?
- Location: Where are you keeping this script safe and sound? And where does it do its thing?
- Frequency of execution: How often does this script get a workout? And where does it flex its muscles?
- Importance: How crucial is this script for business? Is it a big player or more of a supporting act?
- Length: Is this script a short and snappy read or a long and winding tale?
- Cmdlets used and number of calls: What tools does this script rely on, and how often does it call upon them?
- Still required: Can you get the job done with something else, or is this script still the star of the show?
- Improvement points: Could this script do with a bit of a makeover? Maybe a new filter or a modern authentication touch-up?
Overall score: Fancy applying a score to each criteria to help you figure out what needs your attention first? You know, like a boss prioritising tasks. For example, is this script a critical player, or is it more of a background extra?
Got all that? Nice. Let’s move on!
Update your current scripts
Alright, so you’ve documented your scripts – nice one! Now, let’s roll up our sleeves and get them upgraded. Here’s how:
- Start simple / low score: If you’re using a scoring system, kick things off by testing the upgrade with your less complex, non-critical scripts. Get a feel for how things are going before diving into the deep end.
- Map cmdlets: Use the Cmdlet map to find the Microsoft Graph PowerShell versions of your cmdlets. It’s like finding the right key for each door.
- Map parameters / switches: Switch over to Microsoft Graph PowerShell syntax and map out your parameters and switches. It’s all about speaking the same language.
- Map filters: Do the same with your filters, translating them into Microsoft Graph PowerShell syntax. Think of it like translating from one dialect to another.
- Check cmdlet documentation: Keep an eye out for updates from real people adding examples for using the new cmdlets. It’s like getting tips from the pros.
- Use dedicated apps and adhere to least privilege: Because Microsoft Graph PowerShell permissions aren’t pre-authorized, you’ll need to request permissions based on your needs. It’s all about playing it safe.
- Understand required permissions: Use Find-MgGraphCommand and Find-MgGraphPermission to suss out what permissions your cmdlets need. It’s like knowing which keys unlock which doors.
- Understand output objects: Get to grips with the changes in output objects in Microsoft Graph PowerShell. The Get-Member cmdlet will be your best mate for understanding what’s what.
- Optionally, understand the underlying API: Want to go even deeper? Use Find-MgGraphCommand to track down the API path a cmdlet calls. And if you’re feeling really adventurous, dive into Graph Explorer to explore the underlying API calls. Just be sure to reference the API reference content along the way for extra guidance.
ExampleThe equivalent of the Get-AzureADUser cmdlet is Get-MgUser. This cmdlet has additional parameters that let you do more with its output. For example, the -ConsistencyLevel parameter that allows you to do Count, Filter, and Search.
Connect-MgGraph -Scopes ‘User.Read.All’
Get-MgUser -ConsistencyLevel eventual -Count userCount -Filter “startsWith(DisplayName, ‘a’)” -Top 1
Are there Limitations with Graph?
The short answer is yes. Let’s talk about the nitty-gritty limitations you might bump into with Microsoft Graph PowerShell:
- For the equivalent of -SearchString, you’ll need to use -Search and -ConsistencyLevel eventual in all cases. Keep in mind, the query might still work without ‘eventual’. Alternatively, you can use -Filter instead. So, for instance, if you want to find a user named ‘Lee Gu’, you’d use Get-MgUser -Filter “DisplayName eq ‘Lee Gu'”.
- When it comes to passing nested parameters, you’ll need to use hash tables. Think of it like packing your luggage – everything needs its own little compartment. Check out a sample of nested parameters to get the hang of it.
- Pro-tip alert! Make the most of the Microsoft Graph PowerShell -ConsistencyLevel parameter. It’s a game-changer, allowing you to do things like count with $count! For more juicy details, dive into Advanced query parameters.
What’s next?
Alright, let’s talk about what’s next on your to-do list:
- Uninstall AzureAD PowerShell: Before diving into the new stuff, make sure to bid farewell to the old module. Give it a good uninstall to clear the way for the shiny new Microsoft Graph PowerShell.
- Install the Microsoft Graph PowerShell SDK: Ready to jump into the future? Follow these step-by-step instructions to get the Microsoft Graph PowerShell SDK up and running. It’s like installing a new app on your phone – but for your scripts.
- Cmdlet map: Feeling a bit lost in the transition? No worries! Use the Cmdlet map to find the Microsoft Graph PowerShell equivalents of your old cmdlets. It’s like a treasure map leading you to all the new goodies.
Check our Microsoft’s advanced query parameters here