pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Graph calls fail with App-Only Certificate #2725

Closed pkbullock closed 4 years ago

pkbullock commented 4 years ago

Which version of the PnP-PowerShell Cmdlets are you using?

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name sharepointpnppowershell* -ListAvailable)

How did you install the PnP-PowerShell Cmdlets?

This is related to issue #2679, with an exactly same conditions when running commands specifically Get-PnPGrantAccessToken I get an error message "Unable to find an entry point named 'GetPerAdapterInfo' in DLL 'iphlpapi.dll' - inside a Azure Automation script.

SharePoint API calls work though, does the fix need to be applied to the Graph calls as well?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

pkbullock commented 4 years ago

Also fails when using ClientId/ClientSecret/AADTenant parameter combination. Sample code:

Connect-PnPOnline -ClientId $appId -ClientSecret $appSecret -AADDomain $appAdTenant
$token = Get-PnPGraphAccessToken #Get-PnPGraphAccessToken

# Create header
$header = @{ Authorization = "Bearer $($token)" }
$uri = 'https://graph.microsoft.com/beta/groups?$filter=id eq ''' + $groupID + ''' and resourceProvisioningOptions/Any(x:x eq ''Team'')&select=id,resourceProvisioningOptions'

$response = Invoke-RestMethod -Uri $uri -Headers $header -Method Get -ContentType "application/json" # Return null if not found

This works on a local machine. Running the latest June 2020 update.

pkbullock commented 4 years ago

The other ticket has been assigned #2726, closing as this is now a duplicate.