Skip to content

Instantly share code, notes, and snippets.

Avatar

Are Flyen aflyen

View GitHub Profile
View Add-CorpLog.ps1
# Log event to file
function Add-CorpLog
{
param(
[Parameter(Mandatory=$true)]
[string]$Message
)
if ($CorpWriteLogToConsole -eq $True)
{
View Get-CorpMicrosoftGraphAccessToken.ps1
# 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 = ""
View Create-CustomTaxonomyTerm.ps1
# 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
View Create-CustomSPCommunicationSite.ps1
# 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
View PowerShellDefaultHeader.ps1
<# .SYNOPSIS
Title of the script
.DESCRIPTION
Description of the script
.NOTES
Author : Are Flyen
Date : 27.05.2017
.LINK
http://blog.areflyen.no
#>
View Restrict-O365GroupsCreation.ps1
<# .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
#>
View sp-migration-info.js
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);
View CreateListFromCustomTemplate.ps1
#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
View Set-O365AzureAdUserLanguage.ps1
# Settings
$Username = "aflyen@northcorp.no"
# Connect to Azure AD
Connect-AzureAD
# Get user
$User = Get-AzureADUser -ObjectId $Username
Write-Host "Before: $($User.PreferredLanguage)"
View Set-O365UserMailboxLanguage.ps1
# Settings
$username = "aflyen@northcorp.no"
# Connect to Exchange Online
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "https://outlook.office365.com/powershell-liveid/" -Credential $cred -Authentication Basic -AllowRedirection
Import-PSSession $Session
# Get current mailbox language settings
$Settings = Get-MailboxRegionalConfiguration -Identity $username
Write-Host "Before: $($Settings.Language)"
You can’t perform that action at this time.