Skip to content

Instantly share code, notes, and snippets.

@NielsGregers
Last active February 4, 2021 09:58
Show Gist options
  • Save NielsGregers/a7f00ac6a5c8eb3c150c876d33c22fdc to your computer and use it in GitHub Desktop.
Save NielsGregers/a7f00ac6a5c8eb3c150c876d33c22fdc to your computer and use it in GitHub Desktop.
<#
Copyright (c) Niels Gregers Johansen.
MIT License
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
#>
<#
The following environment variables are required
SITEURL=https://(***** TENANT *****).sharepoint.com/sites/hexatown
EXCHCERTIFICATEPATH=(***** PATH TO PFX FILE *****)
EXCHCERTIFICATEPASSWORD=(***** PASSWORD *****)
EXCHORGANIZATION=(***** TENANT *****).onmicrosoft.com
EXCHAPPID=(***** APPID ******)
AADDOMAIN=(***** TENANT *****).onmicrosoft.com
SHAREPOINTADMIN=https://(***** TENANT *****)-admin.sharepoint.com/
DEVELOP=1
GLOBALADMINUPN=(***** YOU *****)@(***** TENANT *****).onmicrosoft.com
#>
. "$PSScriptRoot\.hexatown.com.ps1" # Load the Hexatown framework
$hexatown = Init $myInvocation $true # Start the framework and connect to Exchange Online
# You will have to install Microsoft.Online.SharePoint.PowerShell manually
# $module = "Microsoft.Online.SharePoint.PowerShell" # put in variable to save columns
# Load-Hexatown-Module $hexatown $module # Prereq is that you have run ./installmodule.ps1
Connect-AzureAD
<# If you don't have a template, set a # in start of this line
# https://docs.microsoft.com/en-us/azure/active-directory/enterprise-users/groups-settings-cmdlets
$TemplateId = (Get-AzureADDirectorySettingTemplate | where { $_.DisplayName -eq "Group.Unified" }).Id
$Template = Get-AzureADDirectorySettingTemplate | where -Property Id -Value $TemplateId -EQ
$Setting = $Template.CreateDirectorySetting()
$Setting["EnableMIPLabels"] = "True"
New-AzureADDirectorySetting -DirectorySetting $Setting
#>
<# If you already have a template, set a # in start of this line
$Setting = Get-AzureADDirectorySetting -Id (Get-AzureADDirectorySetting | where -Property DisplayName -Value "Group.Unified" -EQ).id
$Setting["EnableMIPLabels"] = "True"
Set-AzureADDirectorySetting -DirectorySetting $Setting
#>
<# If you haven't setup AIP integration in SharePoint already, set a # in start of this line
Connect-SPOService -Url $ENV:SHAREPOINTADMIN # Will bring up a browser for you to sign in with
Set-SPOTenant -EnableAIPIntegration $true # https://docs.microsoft.com/en-us/microsoft-365/compliance/sensitivity-labels-sharepoint-onedrive-files?view=o365-worldwide#run-the-powershell-command-to-enable-support-for-sensitivity-labels
#>
$upn = $env:GLOBALADMINUPN # put in variable to save columns
Connect-IPPSSession -UserPrincipalName $upn # Connect to compliance center
Execute-AzureAdLabelSync # https://docs.microsoft.com/en-us/powershell/module/exchange/execute-azureadlabelsync?view=exchange-ps
Stop-Hexatown $hexatown # Stop the framework
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment