Skip to content
Browse files

Include steps in the readme on how to configure the environment

  • Loading branch information...
rohitramu committed Jul 15, 2019
1 parent c828328 commit 2460c27bf7b5a3d28bcb1b50eccbe2f14f4663b3
Showing with 62 additions and 25 deletions.
  1. +62 −25
@@ -1,20 +1,21 @@
# Table of Contents
- [Table of Contents](#table-of-contents)
- [Intune-PowerShell-SDK](#intune-powershell-sdk)
- [Getting started](#getting-started)
- [One-time setup (PowerShell Gallery)](#one-time-setup-powershell-gallery)
- [One-time setup (GitHub)](#one-time-setup-github)
- [Before this module is used in your organization](#before-this-module-is-used-in-your-organization)
- [Each time you use the module](#each-time-you-use-the-module)
- [Discovering available commands](#discovering-available-commands)
- [Example usage](#example-usage)
- [Retrieving objects](#retrieving-objects)
- [Creating objects](#creating-objects)
- [Modifying objects](#modifying-objects)
- [Deleting objects](#deleting-objects)
- [Calling functions and actions](#calling-functions-and-actions)
- [Notable features](#notable-features)
- [Known issues and workarounds](#known-issues-and-workarounds)
- [Table of Contents](#Table-of-Contents)
- [Intune-PowerShell-SDK](#Intune-PowerShell-SDK)
- [Getting started](#Getting-started)
- [One-time setup (PowerShell Gallery)](#One-time-setup-PowerShell-Gallery)
- [One-time setup (GitHub)](#One-time-setup-GitHub)
- [Before this module is used in your organization](#Before-this-module-is-used-in-your-organization)
- [Each time you use the module](#Each-time-you-use-the-module)
- [Discovering available commands](#Discovering-available-commands)
- [Example usage](#Example-usage)
- [Retrieving objects](#Retrieving-objects)
- [Creating objects](#Creating-objects)
- [Modifying objects](#Modifying-objects)
- [Deleting objects](#Deleting-objects)
- [Calling functions and actions](#Calling-functions-and-actions)
- [Tips and Tricks](#Tips-and-Tricks)
- [Notable features](#Notable-features)
- [Known issues and workarounds](#Known-issues-and-workarounds)

# Intune-PowerShell-SDK
This repository contains the source code for the PowerShell module which provides support for the Intune API through Microsoft Graph.
@@ -31,42 +32,68 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
Install-Module -Name Microsoft.Graph.Intune

## One-time setup (GitHub)
1. Download the module from the [Releases]( tab in the GitHub repository.
2. The "drop\outputs\build\Release\net471" folder in the zip file contains the module.
- If you are using Windows, extract the "net471" folder. **You must have .NET 4.7.1 or higher installed**.
- If you are using Windows, extract the "net471" folder. **You must have .NET 4.7.1 or higher installed**.
3. The module manifest is the "Microsoft.Graph.Intune.psd1" file inside this folder. This is the file you would refer to when importing the module.
4. Import the module:
Import-Module $sdkDir/Microsoft.Graph.Intune.psd1

## Before this module is used in your organization
An admin user must provide consent for this app to be used in their organization. This can be done with the following command:
Connect-MSGraph -AdminConsent

## Each time you use the module
To authenticate with Microsoft Graph (this is not required when using CloudShell):
To authenticate with Microsoft Graph using [System.Management.Automation.PSCredential]

To authenticate with Microsoft Graph using a [PSCredential] object:
$adminUPN=Read-Host -Prompt "Enter UPN"
$adminPwd=Read-Host -AsSecureString -Prompt "Enter password for $adminUPN"
$creds = New-Object System.Management.Automation.PSCredential ($AdminUPN, $adminPwd)
$connection = Connect-MSGraph -PSCredential $creds
# 1. Create the PSCredential object
$adminUPN = Read-Host -Prompt "Enter UPN"
$adminPwd = Read-Host -AsSecureString -Prompt "Enter password for $adminUPN"
$creds = New-Object System.Management.Automation.PSCredential ($adminUPN, $adminPwd)
# 2. Log in with these credentials
Connect-MSGraph -PSCredential $creds

To authenticate in a non-standard environment:
# 1. Setup the environment
# For example, in a National Cloud environment, the following is required before logging in
Update-MSGraphEnvironment -AuthUrl '' -GraphBaseUrl '' -GraphResourceId '' -SchemaVersion 'beta'
# 2. Log in
# 3. Use the cmdlets
# NOTE: If the schema version has been changed to something other than "v1.0" as in the above
# "Update-MSGraphEnvironment" command, only "Invoke-MSGraphRequest" should be used to make calls,
# because the standard cmdlets (e.g. "Get-IntuneMobileApp") have been generated based on the
# "v1.0" schema, and can produce unexpected results when used with other schema versions
Invoke-MSGraphRequest -HttpMethod GET -Url 'deviceAppManagement/mobileApps'

## Discovering available commands
Get the full list of available cmdlets:
Get-Command -Module Microsoft.Graph.Intune

Get documentation on a particular cmdlet:
Get-Help <cmdlet name>

Use a UI to see the parameter sets more easily:
Show-Command <cmdlet name>
@@ -78,14 +105,17 @@ Get all Intune applications:

Get all Intune device configurations:

Get all Intune managed devices:

Get a filtered list of applications and select only the "displayName" and "publisher" properties:
# The filter string follows the same rules as specified in the OData v4.0 specification.
@@ -122,6 +152,11 @@ $deviceToLock = $allDevices[0]
$deviceToLock | Invoke-IntuneManagedDeviceRemoteLock

## Tips and Tricks
- Create TimeSpan objects using the [New-TimeSpan]( cmdlet
- Create DateTime or DateTimeOffset objects using the [Get-Date]( cmdlet
- If a parameter accepts an "Object" rather than a more specific type, use the documentation to identify what type of object it requires. For example, if the documentation says that a parameter represents a property of type "microsoft.graph.mobileApp" or "microsoft.graph.deviceConfiguration", use the "New-MobileAppObject" or "New-DeviceConfigurationObject" cmdlets to create the respective objects.

# Notable features
- Standard PowerShell objects are used for input/output, meaning that all built-in PowerShell features/utilities/tricks work, including:
- Piping of objects between cmdlets
@@ -141,10 +176,12 @@ $deviceToLock | Invoke-IntuneManagedDeviceRemoteLock

# Known issues and workarounds
- Importing the `MSOnline` cmdlets before importing this `Intune` module will cause errors. Please use the `AzureAD` module instead, as the `MSOnline` module is deprecated.
- If you absolutely must use the `MSOnline` module, it should be imported AFTER the `Intune` module. Note, however, that this is not officially supported.
- If you absolutely must use the `MSOnline` module, it should be imported AFTER the `Intune` module. Note, however, that this is not officially supported.
- If downloaded from Github, the file "Microsoft.Intune.PowerShellGraphSDK.dll" may be blocked when a release is first downloaded. This will stop the assembly from correctly loading (and you will see an error message if you try to import the module).
Dir -Recurse $sdkDir | Unblock-File
- The SDK is built out of Microsoft Graph v1.0 release, some functionality available in the Intune Administration UI is built using the Microsoft Graph beta release.
- Workaround is to use Invoke-RestMethod for such functionality. For more details see:
- Cmdlets in this module are generated based on the "v1.0" version of the Graph schema. In order to access functionality in the "beta" schema you must change the schema version using the command below. However, note that only the `Invoke-MSGraphRequest` cmdlet 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.
Update-MSGraphEnvironment -SchemaVersion 'beta'

0 comments on commit 2460c27

Please sign in to comment.
You can’t perform that action at this time.