Skip to content

PowerShell Functions to query the Microsoft Graph API

License

Notifications You must be signed in to change notification settings

snowboardgeek/MSGraphFunctions

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MSGraphFunctions

PowerShell Gallery PowerShell Gallery

PowerShell Functions to query the Microsoft Graph API.

Note that these functions run on the Microsoft Graph beta endpoint by default. For version 1, specify the -apiVersion "v1.0" switch.

Installing MSGraphFunctions

# Install MSGraphFunctions from the PowerShell Gallery
Install-Module -Name MSGraphFunctions

Prerequisites

  • Requires Azure AD Module installed.

Authenticate to Microsoft Graph

Import-Module MSGraphFunctions

# Authenticate for the first time and grant permissions for the "Microsoft Intune PowerShell" Enterprise Application. (Interactive Authentication (Supports MFA))
Connect-Graph -AdminConsent $true

# Interactive Authentication (Supports MFA)
Connect-Graph

# Non Interactive Authentication (Supports Automation Goals)
$Credential = Get-Credential
Connect-Graph -Credential $Credential

Examples

Example 01 - List all Intune Device Compliance Policies

$compliancePolicies = Get-GraphDeviceCompliancePolicy
$compliancePolicies

Example 02 - Duplicate an Intune Device Configuration Policy

$deviceConfiguration = Get-GraphDeviceConfiguration -id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
$requestBody = $deviceConfiguration | ConvertTo-Json

New-GraphDeviceConfiguration -requestBody $requestBody

Example 03 - Retrieve PowerShell Script Content

# Content of a Single Script
Get-GraphDeviceManagementScript -Id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Get-GraphDeviceManagementScriptContent

# Or
Get-GraphDeviceManagementScriptContent -Id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

# Output PowerShell Script Content of all Uploaded Scripts
Get-GraphDeviceManagementScript | Get-GraphDeviceManagementScriptContent

Example 04 - Delete an Intune Device Compliance Policy

Get-GraphDeviceComplaincePolicy -Id xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | Remove-GraphDeviceComplaincePolicy

About

PowerShell Functions to query the Microsoft Graph API

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PowerShell 100.0%