Native PowerShell support for invoking Microsoft Intune Graph API to enable IT Pro scenario automation.
This repository contains the source code for the PowerShell module which provides support for the Intune API through Microsoft Graph.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
PowerShell Install-Module -Name Microsoft.Graph.Intune
PowerShell Import-Module $sdkDir/Microsoft.Graph.Intune.psd1
An admin user must provide consent for this app to be used in their organization. This can be done with the following command:
PowerShell Connect-MSGraph -AdminConsent
To authenticate with Microsoft Graph (this is not required when using CloudShell):
PowerShell Connect-MSGraph
To authenticate with Microsoft Graph using a [PSCredential] object: ```PowerShell
$adminUPN = Read-Host -Prompt "Enter UPN" $adminPwd = Read-Host -AsSecureString -Prompt "Enter password for $adminUPN" $creds = New-Object System.Management.Automation.PSCredential ($adminUPN, $adminPwd)
Connect-MSGraph -PSCredential $creds ```
To authenticate in a non-standard environment: ```PowerShell
Update-MSGraphEnvironment -AuthUrl 'https://login.microsoftonline.us/common' -GraphBaseUrl 'https://graph.microsoft.us' -GraphResourceId 'https://graph.microsoft.us' -SchemaVersion 'beta'
Connect-MSGraph
Invoke-MSGraphRequest -HttpMethod GET -Url 'deviceAppManagement/mobileApps' ```
Get the full list of available cmdlets:
PowerShell Get-Command -Module Microsoft.Graph.Intune
Get documentation on a particular cmdlet:
PowerShell Get-Help
Use a UI to see the parameter sets more easily:
PowerShell Show-Command
Get all Intune applications:
PowerShell Get-IntuneMobileApp
Get all Intune device configurations:
PowerShell Get-IntuneDeviceConfigurationPolicy
Get all Intune managed devices:
PowerShell Get-IntuneManagedDevice
Get a filtered list of applications and select only the "displayName" and "publisher" properties: ```PowerShell
Get-IntuneMobileApp -Select displayName, publisher -Filter "isof('microsoft.graph.webApp')" ```
Create a web application:
PowerShell $bingWebApp = New-IntuneMobileApp -webApp -displayName 'Bing' -publisher 'Microsoft Corporation' -AppUrl 'https://www.bing.com'
Update the web application that we created in the 'Creating objects' section:
PowerShell $bingWebApp | Update-IntuneMobileApp -webApp -displayName 'Bing Search'
Delete the web application that we created in the 'Creating objects' section:
PowerShell $bingWebApp | Remove-IntuneMobileApp
Lock a managed device: ```PowerShell
$allDevices = Get-IntuneManagedDevice $deviceToLock = $allDevices[0]
$deviceToLock | Invoke-IntuneManagedDeviceRemoteLock ```
Format-Table,
Out-GridView,
ConvertTo-Csv,
ConvertTo-Json, etc.
Get-Help
Show-Command
Connect-MSGraph
Get-MSGraphMetadata
Get-MSGraphNextPageand
Get-MSGraphAllPages
Update-MSGraphEnvironment -Schema beta -AppId 00000000-0000-0000-0000-000000000000
Invoke-MSGraphcmdlet
MSOnlinecmdlets before importing this
Intunemodule will cause errors. Please use the
AzureADmodule instead, as the
MSOnlinemodule is deprecated.
MSOnlinemodule, it should be imported AFTER the
Intunemodule. Note, however, that this is not officially supported.
PowerShell Dir -Recurse $sdkDir | Unblock-File
Invoke-MSGraphRequestcmdlet should be used to make calls to Graph. This is because the difference in entities/properties between "beta" and "v1.0" (the schema that most cmdlets were generated from) can result in unexpected behavior.
PowerShell Update-MSGraphEnvironment -SchemaVersion 'beta'