














前言
最近,因为ACS不能使用了,需要切换用App做认证访问SharePoint Online。
正文
1.新建App Registration,权限选择Site.Selected,如下图:

2.新建证书,添加secret,如下图:

3.新建证书的命令:
# 生成证书存入当前用户库 $cert = New-SelfSignedCertificate ` -Subject "CN=SPOAppCert" ` -CertStoreLocation "Cert:\CurrentUser\My" ` -KeyExportPolicy Exportable ` -NotAfter (Get-Date).AddYears(2) # 导出cer公钥到C:\temp(上传Entra门户) $cert | Export-Certificate -FilePath "C:\temp\spoapp1.cer" # 导出pfx私钥到C:\temp $pwd = ConvertTo-SecureString "123456ABC!" -AsPlainText -Force $cert | Export-PfxCertificate -FilePath "C:\temp\spoapp1.pfx" -Password $pwd
4.执行命令,给站点赋权
# 配置变量 $siteUrl = "https://test.sharepoint.com/sites/test" # 替换上面命令输出的ClientId $pnpClientId = "73a9cd19-84a7-49b6-bd1d-75a798d971e9" # 你要授权的后台Entra应用ClientId(给站点权限的那个App) $targetEntraAppId = "bda3bd11-0fca-4399-8dc4-f4facf787120" # 正确连接:必须带 -ClientId -Interactive $connection = Connect-PnPOnline ` -Url $siteUrl ` -ClientId $pnpClientId ` -Interactive ` -ReturnConnection # 授予站点应用权限(不会再报错) Grant-PnPAzureADAppSitePermission ` -Connection $connection ` -AppId $targetEntraAppId ` -Site $siteUrl ` -Permissions Write # 验证授权 Get-PnPAzureADAppSitePermission -Connection $connection # 断开 Disconnect-PnPOnline -Connection $connection
结束语
这篇是准备环境,下一篇会介绍如何连接。
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。