This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connect to the modern communication site | |
Connect-PnPOnline -Url https://consotos.sharepoint.com | |
# Get the Site Pages library | |
$List = Get-PnPList -Identity "SitePages" -Includes Fields | |
# Go the the Site Pages library, enable audience targeting, add a news template and set a default value. | |
# Get news tempalte with default settings | |
$TemplateItem = Get-PnPListItem -List $List | Where-Object { $_.FieldValues.FileLeafRef -eq "ContosoNews.aspx" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connect to the site | |
Connect-PnPOnline -Url https://contoso.sharepoint.com | |
# Create a new classic Wiki Pages library | |
New-PnPList -Title "Pages-Redirect" -Url "Pages" -Template:WebPageLibrary | |
# Go to the "Pages" library and add a new page "Default" and enter information about where the new site can be found. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requires: Install-Module -Name ExchangeOnlineManagement -RequiredVersion 2.0.5 | |
Import-Module ExchangeOnlineManagement | |
Connect-IPPSSession | |
Execute-AzureAdLabelSync |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Log event to file | |
function Add-CorpLog | |
{ | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$Message | |
) | |
if ($CorpWriteLogToConsole -eq $True) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# .SYNOPSIS | |
Title of the script | |
.DESCRIPTION | |
Description of the script | |
.NOTES | |
Author : Are Flyen | |
Date : 23.03.2023 | |
.LINK | |
https://www.areflyen.no | |
#> |