admin管理员组文章数量:1331083
I am unable to create files/folders in my OneDrive, I got this message: Resolve-PnPFolder : The remote server returned an error: (403) Forbidden
Microsoft changed how to connect via PnP and now no one can connect with a user. I do have an application and I am trying to connect with ClientID and Secret when connecting I am getting this warning:
WARNING: Connecting with Client Secret uses legacy authentication and provides limited functionality. We can for instance not execute requests towards the Microsoft Graph, which limits cmdlets related to Microsoft Teams, Microsoft Planner, Microsoft Flow and Microsoft 365 Groups. You can hide this warning by using Connect-PnPOnline [your parameters] -WarningAction Ignore
I added almost everything in App permissions and still got this message, what could be the reason?
$OneDriveSiteURL = ";
Connect-PnPOnline -Url $OneDriveSiteURL -ClientId "3ed262a0-f02e-48f4-9ede-ef90c76aXXXX" -ClientSecret "dAs8Q~XXXXkdmF4bF3UI1Hke2yxtTgXXXX"
I can tell that we used a Nuget that someone prepared and it worked as expected with the same App registration, we must use PowerShell instead of this Nuget (there is a reason for that...)
I used this and it's working but it creates a folder in SPO and not in OD why?
OneDrive FB create Folder with Microsoft Graph API Powershell
$clientId = "XXXXXXXXXXXXXX"
$tenantId = "XXXXXX.onmicrosoft"
$clientSecret = 'XXXXXXXXXXXX'
$uri = "/$tenantId/oauth2/v2.0/token"
$body = @{
client_id = $clientId
scope = "/.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
Write-Host $token
$uri = ".0/<ID XXXXXXX>/drive/root/children"
$method = 'POST'
$head= @{Authorization = "Bearer $token"}
$postPara= @{
name= "NewFolder"
folder= {}
} | ConvertTo-Json
$antwort = Invoke-RestMethod -Headers $head -Uri $uri -Method $method -Body $postPara -ContentType "application/json"
Write-Host $antwort
本文标签: office365Creating folders in OneDrive via PowerShellStack Overflow
版权声明:本文标题:office365 - Creating folders in OneDrive via PowerShell - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742272370a2444548.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论