r/MsGraphPowerShell • • Sep 29 '24

The Microsoft Graph PowerShell Book - 20% off

38 Upvotes

Check out the Microsoft Graph PowerShell for Administrators book published on Gumroad, offering 20% discount with code:

GRAPHPOWERSHELL20

https://ourcloudnetwork.com/microsoft-graph-powershell-book/

The book aims to help build your proficiency in managing Microsoft 365 services using PowerShell and Microsoft Graph. Not only will you learn how to install, maintain, and authenticate with Microsoft Graph PowerShell, but you'll do so efficiently and securely, using different methods to meet the needs of your business. It is self-published (written, reviewed and sanity-checked by myself)!

  • Pages: 225

  • Words: 38500+

  • Example scripts: 100+

  • Challenges + Practice Questions


r/MsGraphPowerShell • • Jun 16 '24

Tutorial Report and update Per-user MFA with Microsoft Graph PowerShell

5 Upvotes

You can now update your per-user MFA settings for users in Microsoft Entra with Microsoft Graph PowerShell. This has been a welcome change, especially in light of the upcoming enforcement of MFA across Azure services and the pending switchover to modern Authentication methods policies!

GET per-user MFA settings

Connect-MgGraph -scopes Policy.ReadWrite.AuthenticationMethod

Invoke-MgGraphRequest -Method GET -Uri "/beta/users/*USERNAME*/authentication/requirements" -OutputType PSObject

UPDATE per-user MFA settings

Connect-MgGraph -scopes Policy.ReadWrite.AuthenticationMethod

$body = @{"perUserMfaState" = "disabled"}Invoke-MgGraphRequest -Method PATCH `
-Uri "/beta/users/<#USERIDHERE#>/authentication/requirements“ `
-Body $body

You can expand both of these examples to all users in your tenant. I have written two blog posts on the subject


r/MsGraphPowerShell • • Apr 08 '26

Help us push Microsoft to align the Microsoft Graph, Microsoft 365 Admin APIs & Entra ID APIs and other API´s for Consistent Access

4 Upvotes

A bit hard to find the "right" place, so I try here in a general one as it´s "cover" it all almost.

Currently, there is a significant misalignment between Microsoft Graph, Microsoft 365 Admin Portal APIs, Entra ID APIs, and other related endpoints. Many critical configuration and reporting settings are only available through:

These APIs can typically only be accessed via user tokens (delegated context) and often require Global Administrator rights, even for simple read-only (GET) requests. Application permissions via service principals (App Registrations) are often not supported, making automation at scale nearly impossible.

Help us to see if we can get the Microsoft Graph API better here: https://feedbackportal.microsoft.com/feedback/idea/1b538889-b084-f011-8151-7c1e529deacc

All support is welcome - as of now, the top 1 on the feedback portal, but we can get a highter number.


r/MsGraphPowerShell • • May 02 '24

Script Find all license-enabled groups in Microsoft Entra with PowerShell

4 Upvotes

I recently posted about a Microsoft Graph PowerShell script that uses Advanced filtering to find all groups in Microsoft Entra that are assigned licenses.

The filter is quite simple, it will return any groups where the count of assigned licenses does not equal 0.

Get-MgGroup -Filter "assignedLicenses/`$count ne 0" -CountVariable CountVar -ConsistencyLevel eventual

Check out my full post and script to build/export and report on license-enabled groups: https://ourcloudnetwork.com/find-all-license-enabled-groups-in-microsoft-entra-with-powershell/


r/MsGraphPowerShell • • Jan 10 '24

The Microsoft Graph PowerShell Book

4 Upvotes

Hi All,

I'm excited to share that my new ebook (𝐌𝐢𝐜𝐫𝐨𝐬𝐨𝐟𝐭 𝐆𝐫𝐚𝐩𝐡 𝐏𝐨𝐰𝐞𝐫𝐒𝐡𝐞𝐥𝐥 𝐟𝐨𝐫 𝐀𝐝𝐦𝐢𝐧𝐢𝐬𝐭𝐫𝐚𝐭𝐨𝐫𝐬) in its first version, is published on Gumroad.

https://danielbradley.gumroad.com/l/MicrosoftGraphPowerShell

The book aims to help build your proficiency in managing Microsoft 365 services using PowerShell and Microsoft Graph. Not only will you learn how to install, maintain, and authenticate with Microsoft Graph PowerShell, but you'll do so efficiently and securely, using different methods to meet the needs of your business.

It is self-published (written, reviewed and sanity-checked by myself) through early mornings and late evenings! I am also aware of how quickly Microsoft Graph and the SDKs are changing, so when you obtain a copy, you will get updates for the life of the book, access to the change log and access to the private group where I can answer any of your questions.

𝐊𝐞𝐲 𝐢𝐧𝐟𝐨

  • Pages: 202

  • Words: 35000+

  • Example scripts: 100+

  • Challenges: 3

  • Practice Questions: 20+

If you have any questions about the book, drop them below!


r/MsGraphPowerShell • • Jan 03 '24

Tutorial How To Install the Microsoft Graph PowerShell Module

4 Upvotes

In the post, I explain why you should use the MS Graph PowerShell module over traditional PowerShell modules and also show you how to install MS Graph PowerShell.

https://ourcloudnetwork.com/how-to-install-the-microsoft-graph-powershell-sdk/


r/MsGraphPowerShell • • Jan 07 '24

Script Protect Microsoft 365 Break Glass Accounts with Azure Automation

3 Upvotes

I wrote this post to demonstrate how you can use Microsoft Graph PowerShell scripts, combined with Azure Automation, to protect your break-glass accounts in Microsoft Entra ID. Check it out!

https://ourcloudnetwork.com/protect-microsoft-365-break-glass-accounts-with-azure-automation/


r/MsGraphPowerShell • • May 07 '25

Question Get-MgDeviceManagementDeviceConfiguration - omaSettings value weirdness

2 Upvotes

We have an app registration with permissions assigned at application with admin consent Device.ManagementConfiguration.ReadWrite.All

I am trying to read the custome OMA-URI settings in a device configuration policy group. The value is a String (XML file)

$policy = Get-MgDeviceManagementDeviceConfiguration -DeviceConfigurationId "value here"

$policy.AdditionalProperties.omaSettings[3].value (I am sure this is the group element)

Always comes back as 'PGEVPG==' I know that this is a base64 encrypted string and I have tried

XML

the value comes back as '<a/>'

This is not the true value as I can see in Intune that it is a full XML config file.

Had anyone seen this before?


r/MsGraphPowerShell • • Apr 03 '25

Admin consent

2 Upvotes

Can you grant admin consent on specific objects vs the entire tenant for APIs?


r/MsGraphPowerShell • • Jan 29 '25

suppress output at disconnect-mggraph

2 Upvotes

When I disconnect from a MgGraph session, it always displays information about the session with fields like ClientId,TenantId,Scopes,AuthType,TokenCredentialType, etc... Is there a way to stop this information from being displayed?


r/MsGraphPowerShell • • Oct 21 '24

New Cloud licensing APIs (preview) in Microsoft Graph Preview

2 Upvotes

Microsoft have released new a cloud licensing API in Microsoft Graph!

I wrote a short article which explains the difference between these new APIs and the similar endpoints in Microsoft Graph already, such as the Get-MgUser and Get-MgUserLicenseDetail cmdlets! > https://ourcloudnetwork.com/report-license-usage-rights-with-microsoft-graph-powershell/


r/MsGraphPowerShell • • Jun 09 '24

Tutorial Create Device Preparation Policies in Intune with Microsoft Graph PowerShell

2 Upvotes

Device Preparation Policies in Microsoft Intune allow you to deliver the Autopilot device configuration during the user authentication stage of the OOBE (out-of-the-box) experience on new devices. Unlike standard Autopilot profiles where the device hash needs to be pre-uploaded to the Autopilot service, this is not required with Device preparation policies as it targets the user and not the device.

There has been a lot of chatter on this subject over the last week, highlighting the good and bad of this service. Never-the-less, if you need to deploy policies on a large scale across customers, you may want to consider using Microsoft Graph PowerShell!

This article has all you need to know to deploy your Device Preparation policies with PowerShell > https://ourcloudnetwork.com/how-to-deploy-autopilot-device-preparation-policies-with-powershell/


r/MsGraphPowerShell • • May 25 '24

Create client secrets during App Registration in Microsoft Entra

2 Upvotes

You can now create client secrets during the registration of an application in Microsoft Entra! This allows you to reduce the amount of calls to Microsoft Graph that are needed when programmatically creating an app registration.

Here is an example of creating a new app registration with a client secret using Microsoft Graph PowerShell:

Connect-MgGraph -Scopes Application.ReadWrite.All

$body = @{
   displayName = "Ourcloudnetwork App"
   passwordCredentials = @(
        @{
            displayName = "A new client secret"
        }
    )
}

$App = Invoke-MgGraphRequest -Method POST -Uri "/v1.0/applications" -Body $body -OutputType PSObject

You can check out the full upgrade in this article: https://ourcloudnetwork.com/create-client-secrets-during-app-registration-in-microsoft-entra/


r/MsGraphPowerShell • • May 21 '24

Question Getting Windows OS Build version and release Date from Graph?

2 Upvotes

Hi all,
I'm at the brink of insanity over here.

I'm trying to get a List of all OS Build versions and their (latest) Release Date from Graph.
I know i can get the release dates via Graph using Get-MgBetaWindowsUpdatesCatalogEntry.
I also know that Microsoft has the info also listed on their learn page.

I need to grab the build number (i.e. 19045.4412) and the latest availability date (i.e. 2024-05-14) via a recurring task, since our reporting on our devices just spits out the Build.

Any suggestions on how to get this done without scraping the aforementioned Website for all its tables? :)


r/MsGraphPowerShell • • May 14 '24

Command to force a O365 password to expire

2 Upvotes

I have a command to check whether user has a cloud account that's set to never expire seen here:

Get-MGUser -UserID [email protected] -Property UserPrincipalName,PasswordPolicies | Select-Object UserPrincipalName,@{N="PasswordNeverExpires";E={$_.PasswordPolicies -contains "DisablePasswordExpiration"}}

UserPrincipalName PasswordNeverExpires


[email protected]True

I want to change this single user to expire. What's the code for that? I'm testing a process on a large group of users and I'd prefer not to use the GUI.


r/MsGraphPowerShell • • Apr 19 '24

Script Improve the performance of your Microsoft Graph PowerShell scripts with filtering!

2 Upvotes

Using the filtering capabilities of Microsoft Graph is the fastest way to improve the performance of new and existing scripts!

Check out my blog post: https://ourcloudnetwork.com/how-to-use-filter-with-microsoft-graph-powershell/

𝐋𝐞𝐚𝐫𝐧 𝐚𝐛𝐨𝐮𝐭:
• Why -Filter is much better than Where-Object!
• How to run advanced queries!
• How advanced queries are processed, compared to standard queries!
• Why ConsistencyLevel and CountVariable is needed for advanced queries!
• How to combine multiple filter rules!
• How to filter for objects based on a property collection with Lambda operators!


r/MsGraphPowerShell • • Apr 15 '24

Script List all Passkeys and AAGUIDs with Microsoft Graph PowerShell

2 Upvotes

Hi All!

With the announcement of Passkeys in Microsoft Authenticator for Entra, it is a good time to audit which Passkeys have been implemented in your tenant currently and the associated AAGUIDs.

AAGUIDs of each Passkey are required to implement Passkey restrictions in your tenant, which is essential for setting up Passkeys in the Microsoft Authenticator app.

For the full script, see my post: https://ourcloudnetwork.com/list-all-passkeys-and-aaguids-in-microsoft-entra-with-powershell/.

The script is fairly simple, it grabs all the users with Passkeys registered, both with and without the Microsoft Authenticator app, then loops through them and grabs all the necessary information:

$Report = @()

$PasskeyUsers = Invoke-MgGraphRequest -Method GET `
-Uri "beta/reports/authenticationMethods/userRegistrationDetails?`$filter=methodsRegistered/any(i:i eq 'passKeyDeviceBound') OR methodsRegistered/any(i:i eq 'passKeyDeviceBoundAuthenticator')" `
-OutputType PSObject | Select -expand Value

Foreach ($user in $PasskeyUsers) {
    $passkey = Invoke-MgGraphRequest -Method GET -Uri "beta/users/$($user.id)/authentication/fido2Methods" -OutputType PSObject | Select -Expand Value
    $obj = [PSCustomObject][ordered]@{
        "User" = $user.UserPrincipalName
        "Passkey" = $passkey.displayName
        "Model" = $passkey.model
        "aaGuid" = $passkey.aaGuid
        "Date created" = $passkey.createdDateTime
    }
    $Report += $obj
}

$Report | Out-GridView

r/MsGraphPowerShell • • Apr 13 '24

Script Export All Microsoft 365 Users' MFA Status with Microsoft Graph PowerShell

2 Upvotes

I recently updated a script of mine to generate a simple report of all users' MFA status and registered methods using Microsoft Graph PowerShell.

You obtain the information with a single line of code!

Get-MgBetaReportAuthenticationMethodUserRegistrationDetail | Select UserPrincipalName, MethodsRegistered, UserPreferredMethodForSecondaryAuthentication

For details on exporting this information, check out my blog post: Export All Microsoft 365 Users MFA Status with PowerShell


r/MsGraphPowerShell • • Feb 16 '26

Problem with MSGraph and Azure Automation

1 Upvotes

Hi everyone

does anyone know, what the problem ist to MsGraph and Site.ReadWrite.All? I am receveing this Error:

Get-MgSite_List:  Line |  177 |      $allSites = Get-MgSite -Search "*" -All      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~      | General exception while processing Status: 401 (Unauthorized) ErrorCode: generalException Date: 2026-02-16T16:15:20 Headers: ..... 

I checked the API permission on the app and it is the delegated.

Could some help to find out the problem, maybe I missed something.

Thanks


r/MsGraphPowerShell • • Nov 26 '25

Microsoft Graph API - how to add calendar event via PowerShell

Thumbnail reddit.com
1 Upvotes

r/MsGraphPowerShell • • Oct 17 '25

Question Managing permissions for adhoc scripts within MSGraph

1 Upvotes

So we've got a broad group of 3rd line techies in a mixed set of roles supporting Teams, SharePoint, Users and Entra - you name it, we do it. Users have got the roles they need assigned within Entra as permanent, although we are trialling PIM.
We're using Graph in our adhoc query scripts, but we're finding it a real pain in the arse to assign "read.thing.all" permissions within Entra for every little thing our techies need to do - which are going to change regularly.
We want to keep this secure, but want to not slow our techies down. How do other teams do this?


r/MsGraphPowerShell • • Jul 21 '25

Looking for a MSGraph cmdlet.

1 Upvotes

Hi guys,

I'm an IT Specialist working at a company with about 100 ppl and a MSGraph noobiwe.

When we have scam emails, I've always gone to the Compliance portal, created a new content search, and then run the following cmdlet.

"New-ComplianceSearchAction -SearchName "Name of the Content Search" -Purge -PurgeType HardDelete "

I found out that msonline cmdlets has been retried, and was looking for MSGraph cmdlet that does the same job, but was not able to find it yet, and I'm hoping someone could give me some insigts on this.


r/MsGraphPowerShell • • Apr 09 '25

How to get all site names with Graph with delegated permissions

1 Upvotes

I have a powershell script that loops through a number of site ID's to get the site name.

The script needs to use delegated permissions instead of app permissions.

My account does not have permission to access ever single site, but they are a SharePoint administrator.

I'm trying to use the get-mgsite to pull back the site name, but I'm getting 403 errors on any site that I'm not a member of - Does anyone know any clever ways to get the names without using this command


r/MsGraphPowerShell • • Mar 11 '25

E-Discovery Search

Thumbnail
learn.microsoft.com
1 Upvotes

Hi All, I’m in the process of exploring the graph api. I’ve got as far as creating a case & created a search query using the above attached article. If I go into the portal this seems to create the search and query but doesn’t run it. I’ve looked through the documentation but can’t quite see how I trigger this to run?

Any help or suggestions would be greatly appreciated. I’m currently using https requests via invoke-restmethod.