-
Notifications
You must be signed in to change notification settings - Fork 384
Closed
Description
Reporting an Issue
When I run the Get-PnPSite command, I get the error
Get-PnPSite : The remote server returned an error: (401) Unauthorized.
Expected behavior
Get-PnPSite command result
Actual behavior
Steps to reproduce behavior
Script:
# Application (client) ID, tenant ID and secret
$clientId = "<Azure App ID>"
$tenantId = "<Tenant ID>"
$clientSecret = '<secret>'
# Construct URI
$uri = "https://login.microsoftonline.com/$tenantId/oauth2/v2.0/token"
# Construct Body
$body = @{
client_id = $clientId
scope = "https://graph.microsoft.com/.default"
client_secret = $clientSecret
grant_type = "client_credentials"
}
$tokenRequest = Invoke-WebRequest -Method Post -Uri $uri -ContentType "application/x-www-form-urlencoded" -Body $body -UseBasicParsing
$token = ($tokenRequest.Content | ConvertFrom-Json).access_token
Connect-PnPOnline -Url "<MySite URL>" -AccessToken $token
Get-PnPSite
What is the version of the Cmdlet module you are running?
(you can retrieve this by executing Get-Module -Name "PnP.PowerShell" -ListAvailable
)
Which operating system/environment are you running PnP PowerShell on?
- [*] Windows
Metadata
Metadata
Assignees
Labels
No labels