Update SPO Language (User) - robedi/PowerShell GitHub Wiki
This script, executed as part of the Adaxes custom command, is designed to update the language settings for a user's SharePoint Online and OneDrive environment. Here’s a simple explanation of how it works:
-
Loading Necessary Libraries:
The script begins by loading the required Microsoft SharePoint assemblies to work with SharePoint Online, its user profiles, and other services. -
Setting Up Language and Locale Information:
It defines several language options (such as Danish, German, English, etc.) using language ID codes, as well as setting English (locale ID 1033) as the primary language for the SharePoint site. -
Accessing SharePoint Online:
The script retrieves an access token via Azure AD to authenticate with SharePoint Online. This token allows it to connect and manage SharePoint resources for the user without requiring explicit login details. -
Getting the User’s Information:
The script collects the user’s username (sAMAccountName) and constructs the user’s full OneDrive URL based on their company’s domain (in this case,contoso.com). -
Granting Admin Access to OneDrive:
To modify the settings on the user's OneDrive, the script temporarily grants itself admin access to the user’s OneDrive site. -
Updating Language and Locale Settings:
After accessing the user's OneDrive, it changes the regional settings by:- Setting the default locale to English (LocaleID 1033).
- Applying specific collation settings to the site.
- Enabling multilingual support for the user’s SharePoint/OneDrive and adding support for several languages (Danish, German, Dutch, Portuguese, Russian, Swedish, Ukrainian, and more).
-
Finalizing Changes:
Once the regional and language settings are updated, the script applies these changes and removes the admin access it granted earlier to ensure everything goes back to normal.
Summary:
This script automatically configures the language and regional settings for a user's OneDrive and SharePoint site to support multiple languages and sets English as the default. It does this without needing the user's credentials and temporarily grants itself admin access to perform the changes.