2017-02-27 10 views
1

私の目標は、最近登録したデバイスを報告するスケジューリング可能なPowerShellスクリプトを作成することです。私はアプリケーションを作成し、いくつかの権限を与えました。MS Graph API - ManagedDevicesスコープを取得

$OauthTokenEndpoint = 'https://login.microsoftonline.com/tenantid/oauth2/token' 

$OauthRequest = @{ 
    grant_type="client_credentials" 
    client_id = "clientidguid" 
    client_secret = "clientidsecret" 
    resource = "https://graph.microsoft.com" 
    scope="DeviceManagementManagedDevices.Read.All" 
} 

$AuthResponse = Invoke-RestMethod -Uri $OauthTokenEndpoint -Method Post -ContentType application/x-www-form-urlencoded -Body $OauthRequest 
$Token = $authresponse.access_token 

#this query completes successfully 
$Success = Invoke-restmethod -uri https://graph.microsoft.com/v1.0/users/[email protected]/ownedDevices -Headers @{Authorization = "Bearer $Token"} -method Get 

#this query fails with 401 unauthorised 
$401Error = Invoke-RestMethod -Headers @{Authorization = "Bearer $Token"} -uri "https://graph.microsoft.com/beta/managedDevices/deviceguid?`$select=hardwareInformation" -Method GET 

私は私の問題は、私が持っていない、または自分のアプリケーションにDeviceManagementManagedDevices.Read.Allスコープのアクセス許可を与えることができないということであると信じています。このAPIはGraph Explorerと連携して動作します。このスクリプトの対話型バージョンでは、動作する委任されたアクセス許可を使用しています。アプリケーションを非対話的に使用できるように、アプリケーションにManagedDevices APIエンドポイントへのアクセスを許可する方法を教えてください。

答えて

1

ユーザー資格情報のないIntune Graph APIを使用しているMicrosoftからの情報は、現在サポートされていません。

関連する問題