Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
O365 Unified Labelling - Label Priority Fixing
# 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 priorities of all labels
$a=Get-Label
foreach ($i in $a)
{
Write-host $i.Name, $i.Priority
}
# Output should be:
#Public 0
#PublicSub1 1
#PublicSub2 2
#Internal 3
#InternalSub1 4
#InternalSub2 5
#Secret 6
#SecretSub1 7
#SecretSub2 8
# If the priority was NOT correct, then:
# Set the priority of the top level labels (do this first).
Set-Label -Identity "CN=Secret,$MyTenant" -Priority 6
Set-Label -Identity "CN=Internal,$MyTenant" -Priority 3
Set-Label -Identity "CN=Public,$MyTenant" -Priority 0
# If the sub level label order is not correct, then use the following to correct (note, you may only need to set individual entries).
Set-Label -Identity "CN=SecretSub1,$MyTenant" -Priority 7
Set-Label -Identity "CN=SecretSub2,$MyTenant" -Priority 8
Set-Label -Identity "CN=InternalSub1,$MyTenant" -Priority 4
Set-Label -Identity "CN=InternalSub2,$MyTenant" -Priority 5
Set-Label -Identity "CN=PublicSub1,$MyTenant" -Priority 1
Set-Label -Identity "CN=PublicSub2,$MyTenant" -Priority 2
# 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
You can’t perform that action at this time.