Skip to content

Instantly share code, notes, and snippets.

View aflyen's full-sized avatar

Are Flyen aflyen

View GitHub Profile
#region Configuration
$Url = "https://TENANTID.sharepoint.com" # URL of the site
$ListTemplateInternalName = "CorpMenu.stp" # Change this with your own list template
$ListName = "Menu" # Change this with the name of the list to be created
#endregion
#region Create list from template
function addMigrationInfo(sender, args) {
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', function() {
var statusId = SP.UI.Status.addStatus("This site has moved. Please update you bookmarks and visit the new location: <a href='" + url + "'>" + url + "</a>");
SP.UI.Status.setStatusPriColor(statusId, 'yellow');
});
}
// Initialize the statusbar as late as possible, see: https://blog.josequinto.com/2015/06/16/custom-javascript-function-loaded-after-the-ui-has-loaded-in-sharepoint-2013/
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(addMigrationInfo);
<# .SYNOPSIS
Restrict Office 365 Groups creation
.DESCRIPTION
Restrict creation to only users in a specific Azure AD security group. Requires the Azure AD Preview PowerShell module to be installed (this or newer version): https://www.powershellgallery.com/packages/AzureADPreview/2.0.0.98
.NOTES
Author : Are Flyen
.LINK
http://blog.areflyen.no
#>
<# .SYNOPSIS
Title of the script
.DESCRIPTION
Description of the script
.NOTES
Author : Are Flyen
Date : 23.03.2023
.LINK
https://www.areflyen.no
#>
# Configuration
$TenantUrl = "https://contoso.sharepoint.com"
$Username = "danj@contoso.com"
$Password = "Password1"
$SiteTitle = "My Communication Site 1"
$SiteUrl = "https://contoso.sharepoint.com/sites/mycomsite1" # Note this URL must be available (check with "/_api/GroupSiteManager/GetValidSiteUrlFromAlias")
$SiteTemplate = "" # "Topic" => leave empty (default), "Showcase" => "6142d2a0-63a5-4ba0-aede-d9fefca2c767" and "Blank" => "f6cc5403-0d63-442e-96c0-285923709ffc"
# Communication site creation request
# Configuration
$SiteUrl = "https://TENANTID.sharepoint.com"
$TermGroupName = "Contoso"
$TermSetName = "Document Types"
$TermName = "Reports"
$TermLcid = 1033
$TermGuid = "2bdb40fd-02e4-4604-914e-9f8012685be0"
# Get correct termset
Connect-PnPOnline -Url $SiteUrl -Credentials $GlobalCredentialsId
# Connects to Azure Active Directory to authenticate and retrieve a valid access token using a Client ID and secret
function Get-CorpMicrosoftGraphAccessToken
{
param(
[string] $TenantId,
[string] $ClientId,
[string] $ClientSecret
)
$AccessToken = ""
# Log event to file
function Add-CorpLog
{
param(
[Parameter(Mandatory=$true)]
[string]$Message
)
if ($CorpWriteLogToConsole -eq $True)
{
@aflyen
aflyen / Set-CorpMultiLanguageSupport.ps1
Last active November 25, 2021 22:34
Enables multi language support for an existing site in SharePoint Online using the PnP.PowerShell module
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/teamsite1"
$Web = Get-PnPWeb -Includes SupportedUILanguageIds,Language
$AvailableLanguages = Get-PnPAvailableLanguage
# Enable multi language support
$Web.IsMultilingual = $true
# Add UI support for additional languages
foreach ($AvailableLanguage in $AvailableLanguages)
{
@aflyen
aflyen / AddMultiLanguageSupportToSpoSite.cs
Last active November 25, 2021 22:34
Enables multi language support for existing sites in SharePoint Online using CSOM
var siteUri = new Uri("https://contoso.sharepoint.com/sites/teamsite1");
string realm = TokenHelper.GetRealmFromTargetUrl(siteUri);
var accessToken = TokenHelper.GetAppOnlyAccessToken(TokenHelper.SharePointPrincipal, siteUri.Authority, realm).AccessToken;
using (var clientContext = TokenHelper.GetClientContextWithAccessToken(siteUri.ToString(), accessToken))
{
var web = clientContext.Web;
clientContext.Load(web, w => w.SupportedUILanguageIds, w => w.Language, w => w.RegionalSettings.InstalledLanguages);
clientContext.ExecuteQuery();