我在 MacOS 上有以下 powershell 脚本,但没有明确的方法可以使用
set-spotenant
或 Set-PnPTenant
将此标志设置为 false。
cd /Users/user/.local/share/powershell/Modules
Import-Module Microsoft.Online.SharePoint.PowerShell -UseWindowsPowerShell
#Prompt for credentials
#Register-PnPEntraIDApp -ApplicationName "PnP Management Shell" -Tenant <tenantId> -Interactive
$clientId = "<clientid>"
$clientSecret = "<secret>"
$adminUrl = "https://<domain>-admin.sharepoint.com"
Import-Module PnP.PowerShell -UseWindowsPowerShell
Connect-PnPOnline -Url $adminUrl -ClientId $clientId -ClientSecret $clientSecret # connects successfully
set-spotenant -DisableCustomAppAuthentication $false # doesnt work
Set-PnPTenant -DisableCustomAppAuthentication $true # doesnt work
set-spotenant
错误:
The term 'set-spotenant' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Set-PnPTenant
错误:
The remote server returned an error: (401) Unauthorized.
UI 中的任何解决方法,这样我就不必经历使用 Powershell 的痛苦
所以我能够解决这个问题:
这是适用于 Mac 的 powershell 脚本:
- Register-PnPEntraIDAppForInteractiveLogin -ApplicationName "<Application Name>" -SharePointDelegatePermissions "AllSites.FullControl" -Tenant <tenantdomain>.onmicrosoft.com -Interactive
- Connect-PnPOnline -Url https://<tenantdomain>.sharepoint.com -Interactive -ClientId <client_id>
- Set-PnPTenant -DisableCustomAppAuthentication $false