azurepowershellsharepointazure-active-directorymicrosoft-graph-api

Attempting to set DisableCustomAppAuthentication to false for Azure not working from Powershell


I have the following powershell script on MacOS but theres no clear way to set this flag to false neither with set-spotenant nor with Set-PnPTenant.

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

Errors with 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.

Errors with Set-PnPTenant:

The remote server returned an error: (401) Unauthorized.

Any workaround from the UI so that i dont have to go through the pain of usign Powershell


Solution

  • So i was able to resolve this:

    Here is the powershell script for Mac:

    
     - 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