Last active
March 6, 2020 18:47
-
-
Save jkbryan/316e20171b4a619733df6718fb37e4d2 to your computer and use it in GitHub Desktop.
O365 Unified Labelling - Policy Creation
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
# Define credentials | |
$AdminCredentials = Get-Credential "myadmin@oholics.net" | |
# Create the session | |
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $AdminCredentials -Authentication Basic -AllowRedirection | |
# Import the session | |
Import-PSSession $Session -DisableNameChecking | |
# Define the tenant | |
$MyTenant = "CN=Configuration,CN=<TenantID>.onmicrosoft.com,OU=Microsoft Exchange Hosted Organizations,DC=FFO,DC=extest,DC=microsoft,DC=com" | |
# Get the labels to add to the policy | |
$Label1=Get-Label -Identity "CN=My Label,$MyTenant" | |
$Label2=Get-Label -Identity "CN=My Sub Label,$MyTenant" | |
# Create the Label Policy | |
New-LabelPolicy -Name "My Label Policy" -Labels $Label1.name,$Label2.Name -ExchangeLocation "All" | |
# Set the advanced settings on the new policy | |
Set-LabelPolicy -Identity "My Label Policy" -AdvancedSettings @{EnableCustomPermissions="False"} | |
Set-LabelPolicy -Identity "My Label Policy" -AdvancedSettings @{AttachmentAction="Automatic"} | |
Set-LabelPolicy -Identity "My Label Policy" -AdvancedSettings @{HideBarByDefault="False"} | |
Set-LabelPolicy -Identity "My Label Policy" -AdvancedSettings @{RequireDowngradeJustification="True"} | |
# When you are totally finished, disconnect the session | |
Remove-PSSession $Session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment