Git Product home page Git Product logo

powershell-intune-samples's Introduction

page_type products languages extensions noDependencies
sample
ms-graph
powershell
contentType technologies services createdDate
samples
Microsoft Graph
Intune
4/4/2017 9:41:27 AM
true

IMPORTANT

Last year we announced a new Microsoft Intune GitHub repository here based on the Microsoft Graph SDK-based PowerShell module. This legacy Microsoft Intune PowerShell sample scripts GitHub repository is now read-only. Additionally, starting on April 1, 2024, due to updated authentication methods in the Graph SDK-based PowerShell module, the global Microsoft Intune PowerShell application (client) ID based authentication method is being removed.

How this will affect your organization

If you are using the Intune PowerShell application ID (d1ddf0e4-d672-4dae-b554-9d5bdfd93547), you will need to update your scripts with a Microsoft Entra ID registered application ID to prevent your scripts from breaking.

What you need to do to prepare

Before May 6, 2024, update your PowerShell scripts by:

  1. Creating a new app registration in the Microsoft Entra admin center. For detailed instructions, read: Quickstart: Register an application with the Microsoft identity platform.
  2. Update scripts containing the Intune application ID (d1ddf0e4-d672-4dae-b554-9d5bdfd93547) with the new application ID created in step 1.

Review the "Updating App Registration" file for detailed instructions. (https://github.com/microsoftgraph/powershell-intune-samples/blob/master/Updating%20App%20Registration)

Intune Graph Samples

This repository of PowerShell sample scripts show how to access Intune service resources. They demonstrate this by making HTTPS RESTful API requests to the Microsoft Graph API from PowerShell.

Documentation for Intune and Microsoft Graph can be found here Intune Graph Documentation.

These samples demonstrate typical Intune administrator or Microsoft partner actions for managing Intune resources.

The following samples are included in this repository:

  • AdminConsent
  • AndroidEnterprise
  • AppleEnrollment
  • Applications
  • ApplicationSync
  • AppProtectionPolicy
  • Auditing
  • Authentication
  • CertificationAuthority
  • CheckStatus
  • CompanyPortalBranding
  • CompliancePolicy
  • CorporateDeviceEnrollment
  • DeviceConfiguration
  • EnrollmentRestrictions
  • IntuneDataExport
  • LOB_Application
  • ManagedDevices
  • Paging
  • RBAC
  • RemoteActionAudit
  • SoftwareUpdates
  • TermsAndConditions
  • UserPolicyReport

The scripts are licensed "as-is." under the MIT License.

Disclaimer

Some script samples retrieve information from your Intune tenant, and others create, delete or update data in your Intune tenant.  Understand the impact of each sample script prior to running it; samples should be run using a non-production or "test" tenant account. 

Using the Intune Graph API

The Intune Graph API enables access to Intune information programmatically for your tenant, and the API performs the same Intune operations as those available through the Azure Portal.  

Intune provides data into the Microsoft Graph in the same way as other cloud services do, with rich entity information and relationship navigation.  Use Microsoft Graph to combine information from other services and Intune to build rich cross-service applications for IT professionals or end users.     

Prerequisites

Use of these Microsoft Graph API Intune PowerShell samples requires the following:

  • Install the AzureAD PowerShell module by running 'Install-Module AzureAD' or 'Install-Module AzureADPreview' from an elevated PowerShell prompt
  • An Intune tenant which supports the Azure Portal with a production or trial license (https://docs.microsoft.com/en-us/intune-azure/introduction/what-is-microsoft-intune)
  • Using the Microsoft Graph APIs to configure Intune controls and policies requires an Intune license.
  • An account with permissions to administer the Intune Service
  • PowerShell v5.0 on Windows 10 x64 (PowerShell v4.0 is a minimum requirement for the scripts to function correctly)
  • Note: For PowerShell 4.0 you will require the PowershellGet Module for PS 4.0 to enable the usage of the Install-Module functionality
  • First time usage of these scripts requires a Global Administrator of the Tenant to accept the permissions of the application

Getting Started

After the prerequisites are installed or met, perform the following steps to use these scripts:

1. Script usage

  1. Download the contents of the repository to your local Windows machine
  • Extract the files to a local folder (e.g. C:\IntuneGraphSamples)
  • Run PowerShell x64 from the start menu
  • Browse to the directory (e.g. cd C:\IntuneGraphSamples)
  • For each Folder in the local repository you can browse to that directory and then run the script of your choice
  • Example Application script usage:
    • To use the Manage Applications scripts, from C:\IntuneGraphSamples, run "cd .\Applications"
    • Once in the folder run .\Application_MDM_Get.ps1 to get all MDM added applications This sequence of steps can be used for each folder....

2. Authentication with Microsoft Graph

The first time you run these scripts you will be asked to provide an account to authenticate with the service:

Please specify your user principal name for Azure Authentication:

Once you have provided a user principal name a popup will open prompting for your password. After a successful authentication with Azure Active Directory the user token will last for an hour, once the hour expires within the PowerShell session you will be asked to re-authenticate.

If you are running the script for the first time against your tenant a popup will be presented stating:

Microsoft Intune PowerShell needs permission to:

* Sign you in and read your profile
* Read all groups
* Read directory data
* Read and write Microsoft Intune Device Configuration and Policies (preview)
* Read and write Microsoft Intune RBAC settings (preview)
* Perform user-impacting remote actions on Microsoft Intune devices (preview)
* Sign in as you
* Read and write Microsoft Intune devices (preview)
* Read and write all groups
* Read and write Microsoft Intune configuration (preview)
* Read and write Microsoft Intune apps (preview)

Note: If your user account is targeted for device based conditional access your device must be enrolled or compliant to pass authentication.

Contributing

If you'd like to contribute to this sample, see CONTRIBUTING.MD.

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.

Questions and comments

We'd love to get your feedback about the Intune PowerShell sample. You can send your questions and suggestions to us in the Issues section of this repository.

Your feedback is important to us. Connect with us on Stack Overflow. Tag your questions with [MicrosoftGraph] and [intune].

Additional resources

Copyright

Copyright (c) 2017 Microsoft. All rights reserved.

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-intune-samples's People

Contributors

adrian-moore avatar aleisens avatar amitghod avatar baywet avatar chadsimmons avatar davefalkus avatar dcluomax avatar forsbakk avatar jankeskanke avatar jasonjoh avatar jdgs avatar joecrandall avatar jsrice7391 avatar knightwolfjk avatar markstan avatar mbaile-microsoft avatar microsoft-github-policy-service[bot] avatar mr-tbone avatar nokafor avatar officeglobal avatar okieselbach avatar petrich-msft avatar pinnakas avatar ralms avatar richlilly2004 avatar scottduf avatar stgrdk avatar theneiljohnson avatar triplanedave avatar troelsgade avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

powershell-intune-samples's Issues

InvokeDevicesActions example currently remote locks all devices against the provided UPN

The following snippet in the InvokeDeviceActions.ps1 script currently locks all devices for the UPN it is ran against:

Write-Host

Write-Host "Checking if the user" $User.displayName "has any devices assigned..." -ForegroundColor DarkCyan

$Devices = Get-AADUserDevices -UserID $id

####################################################

Invoke-DeviceAction

####################################################

if($Devices){

$DeviceCount = $Devices.count

Write-Host "User has $DeviceCount devices added to Intune..."

if($Devices.id.count -gt 1){



write-host "Looping through devices..."



    foreach($Device in $Devices){



    write-host "User" $User.userPrincipalName "has device" $Device.deviceName

    **## Invoke-DeviceAction -DeviceID $Device.id -RemoteLock -Verbose** This should be commented out!
    #Invoke-DeviceAction -DeviceID $Device.id -Retire -Verbose

    #Invoke-DeviceAction -DeviceID $Device.id -Wipe -Verbose



    }



}

ManagedAppPolicy_Get.ps1 Comes back with Error.

Receive bad request error when running the following script.
I am able to pull the first Managed App Policy, Fails at Managed App Policy - Mobile Apps

Error Message:
Get-ManagedAppsPolicyMobileApps : Request to https://graph.microsoft.com/Beta/deviceAppManagemetn/iosManagedAppProtections('####################')/?$Expand=mobileAppIdentifierDeployments failed with HTTP Status
BadRequest

Get-ManagedAppPolicyMobileApps -id $ManagedAppPolicy.id - ...

  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ManagedAppPolicyMobileApps
      bileApps

Trouble retire&delete devices from CSV file

I thought this would be pretty straight forward but I'm not very experienced with PS so hoping someone can assist.

Goal: Read a list of device ids from CSV file and issue Intune device retire and delete commands for each device ID hopefully without having to answer YES to "Are you sure.." prompt for each device.

$DeviceID = Import-Csv "C:temp\testremove.csv"
foreach ($DevID in $DeviceID)
{
Invoke-DeviceAction -DeviceID $DevID -Retire
Invoke-DeviceAction -DeviceID $DevID -Delete
}
#>

deviceActionResults is always empty

How would I retrieve the deviceActionResults? When I pull in the list of devices in my instance, the deviceActionResult always shows as {} and there is no data, even if the device is showing as retirement pending in the Azure portal. it shpows as being a system.object[], so I tried to see if I could access it directly like this:

$deviceid = "somedeviceid"
$uri = "https://graph.microsoft.com/v1.0/deviceManagement/manageddevices('$DeviceID')?`$select=deviceActionResults"
$result = Invoke-RestMethod -Uri $uri –Headers $authToken –Method Get
$result.deviceActionResults

But all I get there is the same null value. I'm working on cleanup scripts to remove stale devices, and I want to check if they are in a retire pending state and if possible when that was initiated, but can't seem to figure out how to retrieve that.

Size limit on number of objects returned? (managed devices)

There are 1173 devices in the tenant I am running ManagedDevices_Get.ps1 against, but only 1000 is returned by the script. Is there any restrictions on how many can be retrieved? If so, how can we override this to return all devices?

Update ManagedDevices scripts to use v1.0 instead of beta

The scripts provided are still using the beta endpoint of Graph API, it seems that now all endpoints for deviceManagement are available in v1.0, so it might be better to update the script to reflect that.

I guess that would make people more confident to use these scripts in production.

Issues with Managed Devices Script

We have tried using two of the scripts provided, but hit issues with both of them. Firstly, we have tried running ManagedDeviceOverview_Get.ps1 which gets to a certain point, errors and then does not continue. is there a way to get the script to continue on error?
image

So we also tried ManagedDevices_Hardware_Get.ps1, but that only returns 1000 devices out of closer to 2000. Any ideas how we can export more than 1000?

Add-LOBAPP

Hi
Thanks for the new samble script awsome work , 🥇
but when i use Upload-AndroidLob and i look from the azure portal the

Version code displays the version version name and the version code is an empty field.

I am using the android sdk

image

We look forward to have a patch exitsting lob app ps script sample 🔢

Best regards from

Ibrahim

Question: C# equivalent of Upload LOB Application

I know this is not an issue. but i have tried to port this to my C# MVC project, and can't seem to get it to work.
On the fileCommit action it returns commitFileFailed without any reasons.
Would it be possible to also create samples in C#? Can't seem to find any documentation with C# as language..

Bad request when trying delete a device

Hey, when trying to delete a device from intune through invoke-deviceaction got a bad request error:

Invoke-DeviceAction -DeviceID b05dcb23-0a67-4971-864d-59981906640d -Delete
 
WARNUNG: A deletion of a device will only work if the device has already had a retire or wipe request sent to the device...
 
Are you sure you want to delete this device? Y or N?
y
Response content:
{
  "error": {
    "code": "BadRequest",
    "message": "{\r\n  \"_version\": 3,\r\n  \"Message\": \"An error has occurred - Operation ID (for customer support): 00000000-0000-0000-0000-000000
000000 - Activity ID: 5e320693-d3c9-466c-9767-05e65fd74269 - Url: https://fef.amsub0102.manage.microsoft.com/DeviceFE/StatelessDeviceFEService/deviceMa
nagement/managedDevices%28%27b05dcb23-0a67-4971-864d-59981906640d%27%29?api-version=5018-03-23\",\r\n  \"CustomApiErrorPhrase\": \"\",\r\n  \"RetryAfte
r\": null,\r\n  \"ErrorSourceService\": \"\",\r\n  \"HttpHeaders\": \"{}\"\r\n}",
    "innerError": {
      "request-id": "5e320693-d3c9-466c-9767-05e65fd74269",
      "date": "2018-05-24T14:24:43"
    }
  }
}
Invoke-DeviceAction : Request to https://graph.microsoft.com/Beta/deviceManagement/managedDevices('b05dcb23-0a67-4971-864d-59981906640d') failed with 
HTTP Status BadRequest Bad Request
In Zeile:1 Zeichen:1
+ Invoke-DeviceAction -DeviceID b05dcb23-0a67-4971-864d-59981906640d -D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Invoke-DeviceAction

Applications\Application_iOS_Add.ps1 fails

Publishing Microsoft Outlook - email and calendar

You cannot call a method on a null-valued expression.
At C:\Temp\IntunePS\powershell-intune-samples-master\Applications\Application_iOS_Add.ps1:340 char:5

  • $errorResponse = $ex.Response.GetResponseStream()
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

ManagedDeviceOwnership_Set Not finding User's Devices

Hi,

ManagedDeviceOwnership_Set.ps1 doesn't seem to be returning any Devices.

When I run ManagedDevice_Get.ps1 I am only able to see a handful devices even though I have 200+ that I can see in my Intune Azure Portal.

Ultimately, I was trying to troubleshoot why Invoke_DeviceAction_Set.ps1 was returning that the user I've inputted "do not have any owned devices". I've also tried inputting users that are returned when I run ManagedDevice_Get.ps1 but it still seems to have no effect.

I've also tried -IncludeEAS with no change in results.

Trying to run the check_lastSyncDateTime.ps1 and Check_enrolledDateTime.ps1getting an error

hi Guys,

When I try and run the script below I am getting the below error and idea which

  • Install AzureAD module -check
  • Connected to Azure AD- check
  • changed directory to script location- check
  • running PS session as admin\unrestricted-check

which is it not responding?

PS C:\windows\Scripts> .\powershell-intune-samples-master\checkstatus\Check_enrolledDateTime.ps1

Please specify your user principal name for Azure Authentication: ********

Checking for AzureAD module...
Checking if any Intune Managed Device Enrolled Date is within or equal to 1440 minutes...

Minutes Ago: 2017-12-12T10:44:20Z

Response content:
{
"error": {
"code": "UnknownError",
"message": "{"Message":"An internal server error has occurred - Operation ID (for customer support): 00000000-0000-000
0-0000-000000000000 - Activity ID: 7d5225ad-4733-4c8b-be6b-478fabb6f553 - Url: https://fef.msub03.manage.microsoft.com/Device
FE/StatelessDeviceFEService/managedDevices?api-version=5017-09-07&$filter=enrolledDateTime+ge+2017-12-12T10%3a44%3a20Z - Cust
omApiErrorPhrase: "}",
"innerError": {
"request-id": "7d5225ad-4733-4c8b-be6b-478fabb6f553",
"date": "2017-12-13T10:43:18"
}
}
}
C:\windows\Scripts\powershell-intune-samples-master\checkstatus\Check_enrolledDateTime.ps1 : Request to
https://graph.microsoft.com/beta/managedDevices?$filter=enrolledDateTime ge 2017-12-12T10:44:20Z failed with HTTP Status
InternalServerError Internal Server Error
At line:1 char:1

  • .\powershell-intune-samples-master\checkstatus\Check_enrolledDateTime ...
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Check_enrolledDateTime.ps1
    
    
    
    

PS C:\windows\Scripts> .\powershell-intune-samples-master\CheckStatus\Check_lastSyncDateTime.ps1

Checking to see if there are devices that haven't synced in the last 30 days...

Response content:
{
"error": {
"code": "UnknownError",
"message": "{"Message":"An internal server error has occurred - Operation ID (for customer support): 00000000-0000-000
0-0000-000000000000 - Activity ID: faadb462-62df-46ac-a4a5-28fe026bde81 - Url: https://fef.msub03.manage.microsoft.com/Device
FE/StatelessDeviceFEService/managedDevices?api-version=5017-09-07&$filter=lastSyncDateTime+ge+2017-11-13T10%3a54%3a04Z - Cust
omApiErrorPhrase: "}",
"innerError": {
"request-id": "faadb462-62df-46ac-a4a5-28fe026bde81",
"date": "2017-12-13T10:53:03"
}
}
}
C:\windows\Scripts\powershell-intune-samples-master\CheckStatus\Check_lastSyncDateTime.ps1 : Request to
https://graph.microsoft.com/beta/managedDevices?$filter=lastSyncDateTime ge 2017-11-13T10:54:04Z failed with HTTP Status
InternalServerError Internal Server Error
At line:1 char:1

  • .\powershell-intune-samples-master\CheckStatus\Check_lastSyncDateTime ...
  •   + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
      + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Check_lastSyncDateTime.ps1
    
    
    

Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

Hi,

Thanks for the script, I think this will be really helpful. However I am getting an issue when running it.

The line in question is - $authResult = $authContext.AcquireTokenAsync($resourceAppIdURI,$clientId,$redirectUri,$platformParameters,$clientId).Result

The error I get is - Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

I am using Microsoft.IdentityModel.Clients.ActiveDirectory.dll version 3.19.

Any ideas would be really helpful. Also do we think this script will work with an MFA enabled GA account?

Thanks

Sync managed devices by 'lastSyncDate' doesn't work

In https://github.com/microsoftgraph/powershell-intune-samples/blob/master/CheckStatus/Check_lastSyncDateTime.ps1
you sync devices by 'lastSyncDate' using this URI="https://graph.microsoft.com/beta/managedDevices?`$filter=lastSyncDateTime ge $daysago".
But the character ` in front of the query parameter does not allow the request to be executed correctly. This query parameter is simply ignored and you always get all the devices.

Using operators 'gt', 'ge' with dates always gives an empty response (((
It looks like at the moment with the dates correctly works only the operator 'lt'.

mdmAuthority

Do you have a sample for setting mdmAuthority and the method to set

I see you setting this parameter on the BRK3119

Member | Value | Description

unknown | 0 | Unknown
intune | 1 | Intune
sccm | 2 | SCCM
office365 | 3 | Office365

Function Add-ApplicationAssignment acts as Set-

I'm trying to use the function to add a new assignment to an application with existing assignments. As described, I understood it to append to the existing assignments. Instead, it acts like a Set function and overwrites any previous assignments with just the new groupId passed to the function.

ManagedDevices_Get.ps1 Error

I get the following error trying to run ManagedDevices_Get.ps1

PS C:\Windows\system32> C:\scripts\Getintunedevices.ps1

Please specify your user principal name for Azure Authentication: adrian.higuero
[email protected]

Checking for AzureAD module...
Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

PS C:\Windows\system32>

Can anyone help?

Unattended authentication against the Microsoft Graph APIs for Intune

Scenario: As part of a user offboarding process, there is a need to initiate a remote wipe operation against a managed Intune device from an Azure Automation runbook.

This means we need unattended authentication.

I have setup an application in the Microsoft Application Registration Portal which has been granted the necessary permissions to perform the required API calls, such as the DeviceManagementManagedDevices.PrivilegedOperations.All permissions which is required for initiating a remote wipe action.

However, according to the documentation, a wipe action is not supported from an application.

Does this mean that this action is not possible to perform without an interactive session? Or are there other ways to accomplish this?

removing devices not synced in 30+ Check_LastsynDatetime_v2.2.ps1 script-please share

Hi Dave,
I have been following your YouTube video where you used this script “Check_LastsynDatetime_v2.2.ps1” to check last sync date and time but was prompted to specific which management agent to check.

  1. EAS
  2. MDM
  3. EASMDM
  4. ALL
    And then once the devices were found you were prompted on the next action
    Waning are you sure you want to retire and delete the 3 devices? Y or N?

Can you please share the script

AppProtectionPolicies_Get

Is there a way to export Windows 10 polices? Android and iOS work fine. Looking through the script it appears there is nothing written to pull the Win10 policies.

MSI applications

Hello,

Do you already have samples to add a MSI into the Intune Service that you have authenticated with?

ManagedDevices -Retire not run

Hi,

I try to retire one device with :

Invoke-DeviceAction -DeviceID "myid" -Retire -Verbose

The script return :

COMMENTAIRES : https://graph.microsoft.com/Beta/managedDevices/myid/retire
COMMENTAIRES : Sending retire command to myid
COMMENTAIRES : POST https://graph.microsoft.com/Beta/managedDevices/myid/retire with 0-byte payload
COMMENTAIRES : received 0-byte response of content type text/plain

No byte is sent nor received I do not understand. I do not understand. Can anyone help me?

Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

This occurs on my machine throughout using every script within the DeviceConfiguration, Authentication AppleEnrollment folder. I am prompted with "Please specify your user principal name for Azure Authentication:" which I would assume is the name of the account you wish to use with Microsoft Azure. (eg. [email protected]). After entering my credentials, I get the error

Checking for AzureAD module... Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

Versions:
Get-Module AzureAD => Version 2.0.1.16
OS - Win 10.

SAS Uri Expiration

$uploadResponse = UploadAzureStorageChunk $sasUri $id $body;

The SAS Uri has an expiration time associated with it.
If the file is sufficiently large you may go over the expiration time and receive an error such as:

Response status code does not indicate success: 403 (Server failed to authenticate the request. Make sure the value of Authorization header is formed
correctly including the signature.).

In order to extend the time needed for a large upload or slow upload time the endpoint renewUpload should be called on the content file ala:

https://developer.microsoft.com/en-us/graph/docs/api-reference/v1.0/api/intune_apps_mobileappcontentfile_renewupload

Application_MDM_Get.ps1 not finding groupAssignments

Hello

It seems like the Get-ApplicationAssignment function in Application_MDM_Get.ps1 is not able to find an apps GroupAssignments.

Response content:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'groupAssignments'.",
"innerError": {
"request-id": "XXXX",
"date": "2018-02-10T21:24:53"
}
}
}
Get-ApplicationAssignment : Request to https://graph.microsoft.com/Beta/deviceAppManagement/mobileApps/f75daeb6-7ddf-4ee9-bfe1-565abb9f592b/groupAssignments failed with HTTP Status Bad
Request Bad Request
At C:\GitHub\IronstoneIT\powershell-intune-samples\Applications\Application_MDM_Get.ps1:429 char:19

  • ... ssignment = Get-ApplicationAssignment -ApplicationId 'XXX...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-ApplicationAssignment

Reset passcode

If you Reset the passcode. How can you see the new passcode?

client id "d1ddf0e4-d672-4dae-b554-9d5bdfd93547" missing

Hello guys,
On the new tenant, that has been created recently the Enterprise application called "Microsoft Intune Powershell" (with the client id "d1ddf0e4-d672-4dae-b554-9d5bdfd93547") is missing. How can I add it or make it visible. This exists in the other tenants that I had then for a while. Or, maybe I am missing something...

image

Thanks in advance for your help

Powershell Core Compatibility

$tempFile = [System.IO.Path]::GetDirectoryName("$SourceFile") + "\" + [System.IO.Path]::GetFileNameWithoutExtension("$SourceFile") + "_temp.bin"

This script will work with PS Core 6.1, but when constructing this path string, you will receive an invalid path as a result of concatenating "\" (backslash) on a *NIX like system.

Possibly using [System.IO.Path]::PathSeparator as a more agnostic approach might be considered?

No unattended samples

All these samples are for manual execution, when can we see samples suitable for automation? I've yet to find a good way to setup a script to run as a scheduled task or SCORCH process because the authentication requirements are onerous (i.e., requiring typing into a authorization web form, or doing admin consent again through a webform instead of just pre-provisioning permissions to service accounts). Are we likely to see good documentation related to this anytime soon?

Trouble Authenticating Using Auth_From_File.ps1

Keep receiving the following error code when attempting to use the solution outlined in Auth_From_File.

Error Message: Authorization Access Token is null, please re-run authentication...

User Report Error

I'm so happy to find these scripts. The ability to export and import into another tenant will be very helpful to me. It will also help us keep our baselines standards accurate.

However, in running the user report script I've receiving an error in two places and I'm not sure what to do about it. Here is the issue.

OS: Windows
OS Version: 10.0.17134.228
EAS Activated: False
EAS DeviceId:
AAD Registered: True
Enrollment Type:
Management State: managed
Compliance State: noncompliant
Invoke-RestMethod : The remote server returned an error: (400) Bad Request.
At C:\Users\AmyBabinchak\OneDrive\Documents\ReportpPolicyApplied.ps1:1175 char:50

  • ... cyStates = (Invoke-RestMethod -Uri $uri -Headers $authToken -Method G ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    • FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

and also here

Assigned Compliance Policies:
Response content:
{
"error": {
"code": "BadRequest",
"message": "Resource not found for the segment 'groupAssignments'.",
"innerError": {
"request-id": "09a96327-3093-462b-9476-c715d7f6a213",
"date": "2018-09-04T16:55:27"
}
}
}
Get-DeviceCompliancePolicyAssignment : Request to https://graph.microsoft.com/Beta/deviceManagement/deviceCompliancePolicies/49
3c92c4-01e9-46af-b490-5754cf5ccae7/groupAssignments failed with HTTP Status BadRequest Bad Request
At C:\Users\AmyBabinchak\OneDrive\Documents\ReportpPolicyApplied.ps1:1561 char:13

  • $DCPA = Get-DeviceCompliancePolicyAssignment -id $id
    
  •         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    • FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Get-DeviceCompliancePolicyAssignment

No Device Compliance Policies Assigned

I will need some guidance on how to resolve.

Conditionnal Access

Hello

I would like to set Conditionnal Access with Graph, i didnt find the API

Thanks for your Reply

Jean-Yves

Auth_From_File.ps1 error

Hi ,
I get an error when using the Auth_From_File.ps1 script

Cannot convert argument "ctx", with value: "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext", for "AcquireTokenAsync" to type "Microsoft.IdentityModel.Clients.ActiveDire
ctory.AuthenticationContext": "Cannot convert the "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" value of type "Microsoft.IdentityModel.Clients.ActiveDirectory.Authen
ticationContext" to type "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext"."

Managed App Policy powershell script throws an error

I have been working with this script for a few days now and today it stopped functioning today
map

I downloaded a fresh zip of the master scripts and ran it an i am still getting the same error. Was there a change that would prevent this from working? Are there going to be many of these changes as i am writing a program that requires this functionality to be persistent without having to modify too greatly.

Thank You

Error when requesting AuthToken

Running Get-AuthToken is failing with this error:

PS C:\Users\SAMUELGRUMMONS>     $authResult = $authContext.AcquireTokenAsync($resourceAppIdURI,$clientId,$redirectUri,$platformParameters,$userId).Result
Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".
At line:1 char:5
+     $authResult = $authContext.AcquireTokenAsync($resourceAppIdURI,$c ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

This error was also reported on StackOverload:
https://stackoverflow.com/questions/41132164/acquiretokenasync-not-found-for-auth-context-when-trying-to-get-token

Invoke_DeviceAction_Set fails for 'retire' action

The Invoke_DeviceAction_Set.ps1 script successfully obtains user details, as well as the list of managed devices, but fails for the 'retire' action with the following error:

"code": "BadRequest",
"message": "Resource not found for the segment 'managedDevices'.",

The credentials used for graph api authorization are a global tenant administrator, so it's doubtful that permissions are at issue here.

Thanks!
Tristan

Dynamicgroup

Graph provide dymanicgroup of Device create ? With query androïd Device

Bad character on blank lines

There are 43 instances of on the blank lines in this file, causing saving or copy/pasting from RAW to provide invalid PowerShell code.

profile ID

I have a bad feeling some of this is depreceated, but mostly , in a document for setup is this:
$global:profileID - this is the GUID of your DEP profile that you have created in Intune. To get this guid, you must navigate to the Corporate Device Enrollment profile in the Intune portal, and the GUID is located at the end of the URL. Here is an example URL that shows you where the GUID is located:
https://portal.azure.com/#blade/Microsoft_Intune_Enrollment/EditAcProfileBlade/overview/profileId/af897c67-05ac-469f-b6c1-64a9fa41eaea

Specifically, I cannot find editacprofileblade in my tenant, & I am a global admin.
I'm specifically trying ot get this to work :
https://blogs.technet.microsoft.com/smeems/2018/03/07/device-cleanup-with-graph-api/

I've modified it so that it authenticates as user. I know MS added some functionality to intunes, but it doesn't specifiy if their version sends a wipe, or just a retire, so I want to use the CSV function of that first.

Authorization Access Token is null, please re-run authentication...

getting below message after insert my credential

Authorization Access Token is null, please re-run authentication...

If I mark this line as a comment in the script, I will get below error

Checking for AzureAD module...

Request to https://graph.microsoft.com/Beta/deviceAppManagement/mobileAppCategories failed with HTTP Status 401 Unauthorized
Response content:
{
"error": {
"code": "InvalidAuthenticationToken",
"message": "Bearer access token is empty.",
"innerError": {
"request-id": "f97793aa-6e39-41f4-85b9-96b2cd2c7706",
"date": "2018-06-18T22:17:35"
}
}
}

here is my computer details
Win 2k12 R2 DataCenter, 2.0.1.11 AzureADPreview, 2.0.1.10 AzureAD

I can confirm, all scripts are working fine on Windows 10; I have tested on 2 windows 10 and 2 server 2012. Windows 10 worked fine but not on servers.

any idea?

DeviceConfiguration_Export.ps1 - Broken with the versions of Azure AD Preview that I have

Hi,

I'm trying the run the above script from my PC and I get the following error (note, I have changed the actual username for this post):

Please specify your user principal name for Azure Authentication: [email protected]

Checking for AzureAD module...
AzureAD PowerShell module not found, looking for AzureADPreview
Cannot find an overload for "AcquireTokenAsync" and the argument count: "5".

Current installed modules:

ModuleType Version Name


Binary 2.0.0.154 AzureADPreview
Binary 2.0.0.137 AzureADPreview

If I know which version of the AzureADPreview this script was working with, then I can manually install that.

Here's another listening of the installed modules that I have:

Version Name Repository
2.0.0.155 AzureAD PSGallery
2.0.0.154 AzureADPreview PSGallery
1.3.0 Avanade.AzureAD PSGallery
1.2.2 Avanade.AzureAD.Graph PSGallery

The Operating system is Windows 10 Pro

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.