Last active
October 30, 2017 07:03
-
-
Save janegilring/6e437a56b5ae9fc42a37e422b666dcb3 to your computer and use it in GitHub Desktop.
Installation and sample usage of the MSGraphIntuneManagement PowerShell module
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install the module from the PowerShell Gallery | |
Install-Module -Name MSGraphIntuneManagement | |
# After installation, you can view available commands by using Get-Command: | |
Get-Command -Module MSGraphIntuneManagement | |
# Get an access token which can be leveraged for authenticating to the Microsoft Graph API for performing operations against the Intune service | |
$Credential = Get-Credential | |
$ClientId = '34d24e43-0ae1-4ed4-bdea-444073711c55' | |
$Token = Get-MSGraphAuthenticationToken -Credential $Credential -ClientId $ClientId | |
# Get an Azure Active Directory User we want to retrieve Intune devices for | |
$AzureADUser = Get-MSGraphAzureADUser -UserPrincipalName [email protected] -AuthenticationToken $Token | |
# Select one of the user`s devices for targeting a remote action | |
$Device = Get-MSGraphIntuneUserDevice -UserID $AzureADUser.Id -AuthenticationToken $Token | Out-GridView -Title 'Select device to perform remote action against' -OutputMode Single | |
# Invoke a reboot action (other available actions include RemoteLock,ResetPasscode, and FactoryReset) | |
Invoke-MSGraphIntuneDeviceAction -Reboot -DeviceID $Device.id -AuthenticationToken $Token | |
# A trick for making interactive use more conventient is to add a default parameter value for all *-MSGraph* commands: | |
$PSDefaultParameterValues.Add('*-MSGraph*:AuthenticationToken', $Token) | |
# If you put this in your PowerShell profile it will run every time PowerShell starts, and you can call commands from the MSGraphIntuneManagement module without specifying -AuthenticationToken $Token every time | |
$AzureADUser = Get-MSGraphAzureADUser -UserPrincipalName [email protected] | |
$Device = Get-MSGraphIntuneUserDevice -UserID $AzureADUser.Id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment