-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGet-ExoAllSensitivityLabelsCSVExport.ps1
34 lines (32 loc) · 1.18 KB
/
Get-ExoAllSensitivityLabelsCSVExport.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
Export all existing sensitivity labels informations
.DESCRIPTION
Exchange Online PowerShell Module required.
.NOTES
File Name : Get-ExoAllSensitivityLabelsCSVExport.ps1
Author : Sébastien Paulet (SPT Conseil)
Prerequisite : PowerShell V5.1 and Exchange ONline PowerShell Module
Source/Inspiration : https://docs.microsoft.com/fr-fr/powershell/module/exchange/get-exomailbox?view=exchange-ps
.PARAMETER ExportName
Used in CSV export name (use company/tenant name)
.EXAMPLE
.\Get-ExoAllSensitivityLabelsCSVExport.ps1 -ExportName "Contoso"
#>
param(
[Parameter(Mandatory = $true)]
[String]$ExportName
)
$isConnectedBefore = $false
try {
Get-Label | Out-Null
Write-Verbose 'Open compliance center connexion detected'
$isConnectedBefore = $true
} catch {}
if (-not $isConnectedBefore) {
Write-Verbose 'Connecting to compliance center'
Connect-IPPSSession
}
$dateFileString = Get-Date -Format "FileDateTimeUniversal"
mkdir -Force "$pwd\$ExportName\" | Out-Null
Get-Label | select *| Export-Csv -Path "$pwd\$ExportName\SensitivityLabelsExport-$ExportName-$dateFileString.csv" -Delimiter ';' -Encoding UTF8 -NoTypeInformation