我想提取数据集的数据集刷新历史记录。我在PowerShell脚本中使用REST API。我注册了本机应用程序并提供了所有权限,但出现错误“需要管理员批准”。 需要管理员的批准?
运行上述代码时出现错误
需要管理员批准
需要访问组织中的资源的权限,只有 管理员可以授予。请要求管理员授予对此应用的权限 在使用它之前。
拥有管理员帐户?使用该帐户登录返回 申请而未获得您的同意”。注意:我不是我的管理员 云
请帮助我解决此错误需要做什么。还有需要什么批准以及我的管理员如何提供访问权限?
$clientId = "NativeAppClientId"
# Calls the Active Directory Authentication Library (ADAL) to authenticate against AAD
function GetAuthToken {
if (-not (Get-Module AzureRm.Profile)) {
Import-Module AzureRm.Profile
}
$redirectUri = "urn:ietf:wg:oauth:2.0:oob"
$resourceAppIdURI = "https://analysis.windows.net/powerbi/api"
$authority = "https://login.microsoftonline.com/common/oauth2/authorize";
$authContext = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext" -ArgumentList $authority
$authResult = $authContext.AcquireToken($resourceAppIdURI, $clientId, $redirectUri, "Auto")
return $authResult
}
# Get the auth token from AAD
$token = GetAuthToken
# Building Rest API header with authorization token
$authHeader = @{
'Content-Type' = 'application/json'
'Authorization' = $token.CreateAuthorizationHeader()
}
# properly format groups path
$groupsPath = ""
if ($groupID -eq "me") {
$groupsPath = "myorg"
} else {
$groupsPath = "myorg/groups/$groupID"
}
# Check the refresh history
$uri = "https://api.powerbi.com/v1.0/$groupsPath/datasets/$datasetID/refreshes"
Invoke-RestMethod -Uri $uri -Headers $authHeader -Method GET -Verbose