Include steps in the readme on how to configure the environment
This commit is contained in:
Родитель
c8283280e4
Коммит
2460c27bf7
83
README.md
83
README.md
|
@ -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,6 +32,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct](https://ope
|
|||
```PowerShell
|
||||
Install-Module -Name Microsoft.Graph.Intune
|
||||
```
|
||||
|
||||
## One-time setup (GitHub)
|
||||
1. Download the module from the [Releases](https://github.com/Microsoft/Intune-PowerShell-SDK/releases) tab in the GitHub repository.
|
||||
2. The "drop\outputs\build\Release\net471" folder in the zip file contains the module.
|
||||
|
@ -40,22 +42,45 @@ Install-Module -Name Microsoft.Graph.Intune
|
|||
```PowerShell
|
||||
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:
|
||||
```PowerShell
|
||||
Connect-MSGraph -AdminConsent
|
||||
```
|
||||
|
||||
## Each time you use the module
|
||||
To authenticate with Microsoft Graph (this is not required when using CloudShell):
|
||||
```PowerShell
|
||||
Connect-MSGraph
|
||||
```
|
||||
To authenticate with Microsoft Graph using [System.Management.Automation.PSCredential]
|
||||
|
||||
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)
|
||||
$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:
|
||||
```PowerShell
|
||||
# 1. Setup the environment
|
||||
# For example, in a National Cloud environment, the following is required before logging in
|
||||
Update-MSGraphEnvironment -AuthUrl 'https://login.microsoftonline.us/common' -GraphBaseUrl 'https://graph.microsoft.us' -GraphResourceId 'https://graph.microsoft.us' -SchemaVersion 'beta'
|
||||
|
||||
# 2. Log in
|
||||
Connect-MSGraph
|
||||
|
||||
# 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
|
||||
|
@ -63,10 +88,12 @@ Get the full list of available cmdlets:
|
|||
```PowerShell
|
||||
Get-Command -Module Microsoft.Graph.Intune
|
||||
```
|
||||
|
||||
Get documentation on a particular cmdlet:
|
||||
```PowerShell
|
||||
Get-Help <cmdlet name>
|
||||
```
|
||||
|
||||
Use a UI to see the parameter sets more easily:
|
||||
```PowerShell
|
||||
Show-Command <cmdlet name>
|
||||
|
@ -78,14 +105,17 @@ 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
|
||||
# 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](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/new-timespan?view=powershell-6) cmdlet
|
||||
- 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
|
||||
- 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
|
||||
|
@ -146,5 +181,7 @@ $deviceToLock | Invoke-IntuneManagedDeviceRemoteLock
|
|||
```PowerShell
|
||||
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: https://github.com/Microsoft/Intune-PowerShell-SDK/issues/14
|
||||
- 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.
|
||||
```PowerShell
|
||||
Update-MSGraphEnvironment -SchemaVersion 'beta'
|
||||
```
|
||||
|
|
Загрузка…
Ссылка в новой задаче