How to Enable SharePoint Versioning Using PowerShell with MFA
Question details
Administrators need a way to enable document versioning across multiple SharePoint sites in bulk using PowerShell while supporting MFA.

- Product
- Microsoft SharePoint Online
- Device & OS
- not provided
- Scenario
- Bulk enabling version history on SharePoint team sites and libraries when multifactor authentication is enforced on admin accounts.
- Observed behavior
- Standard PowerShell credential commands fail due to MFA restrictions, requiring an interactive authentication method to successfully run the versioning script.
Ensure you have the latest SharePoint Online Management Shell or PnP PowerShell module installed, and always verify your script against a single test site before executing a bulk update.
Use Web Login Parameter in PowerShell
This method forces a browser-based authentication prompt that seamlessly handles multifactor authentication (MFA) requests during script execution.
When multifactor authentication is enabled, traditional credential passing in PowerShell will be blocked. To bypass this, you must instruct PowerShell to use modern web-based authentication.
Using the UseWebLogin parameter allows the script to trigger the standard Microsoft 365 login window, where you can complete your MFA approval via text, call, or authenticator app.
Write or modify your PowerShell script to iterate through the target SharePoint team sites and update the EnableVersioning property on the document libraries.
In your connection command (such as Connect-PnPOnline), add the -UseWebLogin parameter instead of -Credentials.
Run the script. A standard Microsoft login dialog will pop up. Enter your credentials and approve the MFA request on your mobile device.
Check a sample of the updated team sites through the SharePoint admin center or web interface to ensure versioning was successfully enabled.

Use PnP PowerShell Interactive Authentication
For administrators using the modern PnP PowerShell module, the Interactive parameter is the recommended approach for handling MFA.
Manage and Edit Your Documents with WPS Office
While managing complex enterprise configurations like SharePoint versioning requires PowerShell expertise, everyday users and teams need an efficient, lightweight, and highly compatible office suite for creating and editing documents. WPS Office is a free, powerful alternative that seamlessly handles Microsoft Office formats and includes built-in document management features.
- 1. Download the Installer: Visit the official WPS Office website and click the free download button.
- 2. Install the Software: Run the downloaded installer file and follow the quick setup instructions.
- 3. Open Your Documents: Launch WPS Office and instantly open your existing Microsoft Office files without losing formatting.

Frequently Asked Questions
Does the UseWebLogin method work on SharePoint team sites?
Yes, using the UseWebLogin or Interactive parameters fully supports connecting to and modifying settings on modern SharePoint team sites, provided the executing account has the necessary SharePoint Administrator permissions.
Why does standard PowerShell authentication fail when MFA is enabled?
Standard authentication passes a username and password directly without a user interface. MFA requires a secondary interactive verification (like an SMS or app approval), which is blocked by headless credential passing, resulting in an 'access denied' error.
Can I enable major and minor versioning simultaneously using PowerShell?
Yes, PowerShell scripts can be configured to enable both major versions (e.g., 1.0, 2.0) and minor/draft versions (e.g., 1.1, 1.2) by modifying the respective properties (EnableVersioning and EnableMinorVersions) of the SharePoint document library.
Is it possible to fully automate this script without interactive MFA prompts?
To fully automate scripts without user interaction while MFA is enforced across your organization, you must use app-only authentication with certificate-based access registered in Azure AD, rather than executing the script under a user account.




