Skip to content
PowerShell Functions to query the Microsoft Graph API
Branch: master
Clone or download
jseerden Release v.2.3.0 (#2)
* Add interactive authentication and support MFA by default
Latest commit b9354c0 Apr 12, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
MSGraphFunctions
CHANGELOG.md
LICENSE
README.md

README.md

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
You can’t perform that action at this time.