1.Download and install the latest SharePoint Online Management Shell.
2.Connect to SharePoint as a global admin or SharePoint admin in Microsoft 365.
Check the SharePoint Online Management Shell by running the following command in administrative mode in PowerShell.
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
3.If your operating system is using PowerShell 5 or newer, you can also install the SharePoint Online Management Shell by running the following command in administrative mode.
Install-Module -Name Microsoft.Online.SharePoint.PowerShell
4.To ensure you have all available cmdlets, you should always make sure the module is up to date. You can update the SharePoint Online Management Shell by running the following command in administrative mode.
5.To connect with a user name and password, run the following command at the SharePoint Online Management Shell command prompt.
Connect-SPOService -Url https://contoso-admin.sharepoint.com -Credential firstname.lastname@example.org
When prompted with the Windows PowerShell credential request dialog box, type the password for the SharePoint admin account.
6.To connect with multifactor authentication (MFA), run the following command at the SharePoint Online Management Shell command prompt.
Connect-SPOService -Url https://contoso-admin.sharepoint.com
When prompted with the Microsoft SharePoint Online Management Shell dialog box, type the account name and password for a SharePoint administrator account, and then click Sign in..
Follow the instructions in the Microsoft SharePoint Online Management Shell dialog box to provide the additional authentication information, such as a verification code, and then click Sign in.
7.Run the following command.
Set-SPOSite <SiteURL> -DenyAddAndCustomizePages 0
If you change this setting for a user’s OneDrive or a classic team site, it will be overridden by the Custom Script setting in the admin center within 24 hours.
Author: Cary Sun
Cary Sun is an Principal Consultant, He has a strong background specializing in datacenter and deployment solutions, and has spent over 20 years in the planning, design, and implementation of network technologies and Management and system integration.He hold CISCO CERTIFIED INTERNETWORK EXPERT (CCIE No.4531) from 1997.Cary is also a Microsoft Most Valuable Professional (MVP) and Cisco Champion, He is a published author with serveral titles, include blogs on Checkyourlogs.net, author for many books. Specialties: CCIE /CCNA / MCSE / MCITP / MCTS / MCSA / Solution Expert / CCA