Skip to content

Instantly share code, notes, and snippets.

View aflyen's full-sized avatar

Are Flyen aflyen

View GitHub Profile
<# .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
#>
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);
#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
# Settings
$Username = "aflyen@northcorp.no"
# Connect to Azure AD
Connect-AzureAD
# Get user
$User = Get-AzureADUser -ObjectId $Username
Write-Host "Before: $($User.PreferredLanguage)"
# 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)"
# Connect to SharePoint Online site collection and get context
Connect-SPOnline -Url "https://TENANTID.sharepoint.com/sites/news
$Context = Get-SPOContext
$Web = $Context.Site.RootWeb
$Context.Load($Web)
Execute-SPOQuery
# Enable likes ratings
Enable-CustomLikesRatingsOnLibrary -Web $Web -ListRelativeUrl "Pages"
function Enable-CustomLikesRatingsOnLibrary {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true)]
[Microsoft.SharePoint.Client.Web]$Web,
[Parameter(Mandatory=$true)]
[String]$ListRelativeUrl
)
# Get required fields
# Configuration
$WebUrl = "http://teams.contoso.com/sites/team1"
$SiteAdminGroup = "CONTOSO\ContosoSiteAdmins"
# Set the AD group as site collection administrator
$Web = Get-SPWeb $WebUrl
$SiteAdminUser = $Web.EnsureUser($SiteAdminGroup)
$SiteAdminUser.IsSiteAdmin = $true
$SiteAdminUser.Update()
$Context = Get-SPOContext
$Web = $Context.Site.RootWeb
$Context.Load($Web)
Execute-SPOQuery
Enable-CustomItemScheduling -Web $Web -PagesLibraryName "Pages"
function Get-CustomLoadParameter {
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[Microsoft.SharePoint.Client.ClientObject]$Object,
[Parameter(Mandatory=$true)]
[string]$PropertyName
)
# Reference: http://sharepoint.stackexchange.com/questions/126221/spo-retrieve-hasuniqueroleassignements-property-using-powershell