Skip to content

Commit 2460c27

Browse files
committed
Include steps in the readme on how to configure the environment
1 parent c828328 commit 2460c27

File tree

1 file changed

+62
-25
lines changed

1 file changed

+62
-25
lines changed

README.md

Lines changed: 62 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Table of Contents
2-
- [Table of Contents](#table-of-contents)
3-
- [Intune-PowerShell-SDK](#intune-powershell-sdk)
4-
- [Getting started](#getting-started)
5-
- [One-time setup (PowerShell Gallery)](#one-time-setup-powershell-gallery)
6-
- [One-time setup (GitHub)](#one-time-setup-github)
7-
- [Before this module is used in your organization](#before-this-module-is-used-in-your-organization)
8-
- [Each time you use the module](#each-time-you-use-the-module)
9-
- [Discovering available commands](#discovering-available-commands)
10-
- [Example usage](#example-usage)
11-
- [Retrieving objects](#retrieving-objects)
12-
- [Creating objects](#creating-objects)
13-
- [Modifying objects](#modifying-objects)
14-
- [Deleting objects](#deleting-objects)
15-
- [Calling functions and actions](#calling-functions-and-actions)
16-
- [Notable features](#notable-features)
17-
- [Known issues and workarounds](#known-issues-and-workarounds)
2+
- [Table of Contents](#Table-of-Contents)
3+
- [Intune-PowerShell-SDK](#Intune-PowerShell-SDK)
4+
- [Getting started](#Getting-started)
5+
- [One-time setup (PowerShell Gallery)](#One-time-setup-PowerShell-Gallery)
6+
- [One-time setup (GitHub)](#One-time-setup-GitHub)
7+
- [Before this module is used in your organization](#Before-this-module-is-used-in-your-organization)
8+
- [Each time you use the module](#Each-time-you-use-the-module)
9+
- [Discovering available commands](#Discovering-available-commands)
10+
- [Example usage](#Example-usage)
11+
- [Retrieving objects](#Retrieving-objects)
12+
- [Creating objects](#Creating-objects)
13+
- [Modifying objects](#Modifying-objects)
14+
- [Deleting objects](#Deleting-objects)
15+
- [Calling functions and actions](#Calling-functions-and-actions)
16+
- [Tips and Tricks](#Tips-and-Tricks)
17+
- [Notable features](#Notable-features)
18+
- [Known issues and workarounds](#Known-issues-and-workarounds)
1819

1920
# Intune-PowerShell-SDK
2021
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
3132
```PowerShell
3233
Install-Module -Name Microsoft.Graph.Intune
3334
```
35+
3436
## One-time setup (GitHub)
3537
1. Download the module from the [Releases](https://github.com/Microsoft/Intune-PowerShell-SDK/releases) tab in the GitHub repository.
3638
2. The "drop\outputs\build\Release\net471" folder in the zip file contains the module.
37-
- If you are using Windows, extract the "net471" folder. **You must have .NET 4.7.1 or higher installed**.
39+
- If you are using Windows, extract the "net471" folder. **You must have .NET 4.7.1 or higher installed**.
3840
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.
3941
4. Import the module:
4042
```PowerShell
4143
Import-Module $sdkDir/Microsoft.Graph.Intune.psd1
4244
```
45+
4346
## Before this module is used in your organization
4447
An admin user must provide consent for this app to be used in their organization. This can be done with the following command:
4548
```PowerShell
4649
Connect-MSGraph -AdminConsent
4750
```
51+
4852
## Each time you use the module
4953
To authenticate with Microsoft Graph (this is not required when using CloudShell):
5054
```PowerShell
5155
Connect-MSGraph
5256
```
53-
To authenticate with Microsoft Graph using [System.Management.Automation.PSCredential]
57+
58+
To authenticate with Microsoft Graph using a [PSCredential] object:
5459
```PowerShell
55-
$adminUPN=Read-Host -Prompt "Enter UPN"
56-
$adminPwd=Read-Host -AsSecureString -Prompt "Enter password for $adminUPN"
57-
$creds = New-Object System.Management.Automation.PSCredential ($AdminUPN, $adminPwd)
58-
$connection = Connect-MSGraph -PSCredential $creds
60+
# 1. Create the PSCredential object
61+
$adminUPN = Read-Host -Prompt "Enter UPN"
62+
$adminPwd = Read-Host -AsSecureString -Prompt "Enter password for $adminUPN"
63+
$creds = New-Object System.Management.Automation.PSCredential ($adminUPN, $adminPwd)
64+
65+
# 2. Log in with these credentials
66+
Connect-MSGraph -PSCredential $creds
67+
```
68+
69+
To authenticate in a non-standard environment:
70+
```PowerShell
71+
# 1. Setup the environment
72+
# For example, in a National Cloud environment, the following is required before logging in
73+
Update-MSGraphEnvironment -AuthUrl 'https://login.microsoftonline.us/common' -GraphBaseUrl 'https://graph.microsoft.us' -GraphResourceId 'https://graph.microsoft.us' -SchemaVersion 'beta'
74+
75+
# 2. Log in
76+
Connect-MSGraph
77+
78+
# 3. Use the cmdlets
79+
# NOTE: If the schema version has been changed to something other than "v1.0" as in the above
80+
# "Update-MSGraphEnvironment" command, only "Invoke-MSGraphRequest" should be used to make calls,
81+
# because the standard cmdlets (e.g. "Get-IntuneMobileApp") have been generated based on the
82+
# "v1.0" schema, and can produce unexpected results when used with other schema versions
83+
Invoke-MSGraphRequest -HttpMethod GET -Url 'deviceAppManagement/mobileApps'
5984
```
6085

6186
## Discovering available commands
6287
Get the full list of available cmdlets:
6388
```PowerShell
6489
Get-Command -Module Microsoft.Graph.Intune
6590
```
91+
6692
Get documentation on a particular cmdlet:
6793
```PowerShell
6894
Get-Help <cmdlet name>
6995
```
96+
7097
Use a UI to see the parameter sets more easily:
7198
```PowerShell
7299
Show-Command <cmdlet name>
@@ -78,14 +105,17 @@ Get all Intune applications:
78105
```PowerShell
79106
Get-IntuneMobileApp
80107
```
108+
81109
Get all Intune device configurations:
82110
```PowerShell
83111
Get-IntuneDeviceConfigurationPolicy
84112
```
113+
85114
Get all Intune managed devices:
86115
```PowerShell
87116
Get-IntuneManagedDevice
88117
```
118+
89119
Get a filtered list of applications and select only the "displayName" and "publisher" properties:
90120
```PowerShell
91121
# The filter string follows the same rules as specified in the OData v4.0 specification.
@@ -122,6 +152,11 @@ $deviceToLock = $allDevices[0]
122152
$deviceToLock | Invoke-IntuneManagedDeviceRemoteLock
123153
```
124154

155+
## Tips and Tricks
156+
- Create TimeSpan objects using the [New-TimeSpan](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/new-timespan?view=powershell-6) cmdlet
157+
- Create DateTime or DateTimeOffset objects using the [Get-Date](https://docs.microsoft.com/en-us/powershell/module/Microsoft.PowerShell.Utility/Get-Date?view=powershell-6) cmdlet
158+
- 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.
159+
125160
# Notable features
126161
- Standard PowerShell objects are used for input/output, meaning that all built-in PowerShell features/utilities/tricks work, including:
127162
- Piping of objects between cmdlets
@@ -141,10 +176,12 @@ $deviceToLock | Invoke-IntuneManagedDeviceRemoteLock
141176

142177
# Known issues and workarounds
143178
- Importing the `MSOnline` cmdlets before importing this `Intune` module will cause errors. Please use the `AzureAD` module instead, as the `MSOnline` module is deprecated.
144-
- If you absolutely must use the `MSOnline` module, it should be imported AFTER the `Intune` module. Note, however, that this is not officially supported.
179+
- If you absolutely must use the `MSOnline` module, it should be imported AFTER the `Intune` module. Note, however, that this is not officially supported.
145180
- 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).
146181
```PowerShell
147182
Dir -Recurse $sdkDir | Unblock-File
148183
```
149-
- 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.
150-
- Workaround is to use Invoke-RestMethod for such functionality. For more details see: https://github.com/Microsoft/Intune-PowerShell-SDK/issues/14
184+
- 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.
185+
```PowerShell
186+
Update-MSGraphEnvironment -SchemaVersion 'beta'
187+
```

0 commit comments

Comments
 (0)