Skip to content

Instantly share code, notes, and snippets.

# some non-graph command
Get-Process notepad
Import-Module Microsoft.Graph.Beta.DeviceManagement -RequiredVersion 2.8.0
Connect-MgGraph
Invoke-MgGraphRequest -Uri "v1.0/auditLogs/directoryAudits?filter=activityDateTime ge $startDate" -OutputType PSObject
Get-MgApplication -ApplicationId c2bca180-36fc-46de-b9a9-5341ada4dd34
@ztrhgf
ztrhgf / someGraphRelatedCode.ps1
Created March 9, 2024 16:27
C:\scripts\someGraphRelatedCode.ps1
# relative v1.0 URI
Invoke-MgGraphRequest -Uri "v1.0/auditLogs/directoryAudits?filter=activityDateTime ge $startDate" -OutputType PSObject
# absolute beta URI, special (PATCH) request method
Invoke-MgGraphRequest -Method PATCH -Uri "https://graph.microsoft.com/beta/identity/conditionalAccess/policies" -Body $body
# relative URI with variable instead of ID
Invoke-MgGraphRequest -Uri "v1.0/groups/$($group.Id)/settings" -Method POST -Body $json -ContentType "application/json"
# URI defined via positional argument