This commit is contained in:
2023-07-04 12:59:44 +02:00
parent 2cef42a718
commit 09c2faad93
231 changed files with 261001 additions and 4 deletions

View File

@ -0,0 +1,33 @@
# Importer le module Exchange Online
Import-Module ExchangeOnlineManagement
#Store the data from ADUsers.csv in the $ADUsers variable
$Mailboxes = Import-csv "Templates\Import-SharedMailbox.csv" -Delimiter ";" -Encoding UTF8
#Loop through each row containing user details in the CSV file
foreach ($Mailbox in $Mailboxes) {
if ((Get-MsolUser -UserPrincipalName $Mailbox.username -ErrorAction SilentlyContinue)) {
Write-Warning "A Shared Mailbox with UPN $($Mailbox.username) already exist in Azure Active Directory."
}
else {
try {
New-Mailbox -Shared -Name $Mailbox.Name -DisplayName $Mailbox.Name -Alias $Mailbox.Alias -PrimarySmtpAddress $Mailbox.username
Write-Host "The Shared Mailbox $($Mailbox.Name) ($($Mailbox.username)) was created." -ForegroundColor Green
}
catch {
Write-Error "The Shared Mailbox $($Mailbox.Name) ($($Mailbox.username)) was not created."
}
foreach ($Member in ($Mailbox.Members).split(",")) {
try {
Add-MailboxPermission $Mailbox.username -User $Member -AccessRights FullAccess -InheritanceType all
Write-Host "$($Members) added to the Shared Mailbox $($Mailbox.username)."
}
catch {
Write-Error "$($Members) not added to the Shared Mailbox $($Mailbox.username)."
}
}
}
}

View File

@ -0,0 +1,6 @@
# Connexion Exchange Online
Connect-ExchangeOnline
# Définir les options de base comme la langue et le fuseau horaire
Get-Mailbox -ResultSize unlimited | Set-MailboxRegionalConfiguration -Language fr-FR -TimeZone "Romance Standard Time" -DateFormat "dd/MM/yyyy" -LocalizeDefaultFolderName:$true

View File

@ -0,0 +1,39 @@
$Compte = Read-Host "Choisir un compte (user@domaine.fr)"
$Action = Read-Host "V pour voir ou M pour voir et modifier"
# $Excluded = Read-Host "Compte Exclus séparé par des virgules"
# Where-Object Identity -notlike "*Meeting4Display*" | Where-Object Identity -notlike "*notification*"
$Excluded = @('*Meeting4Display*', '*notification*')
$AuditMailboxe = Get-Mailbox -Identity $Compte
$Mailboxes = Get-Mailbox -ResultSize Unlimited | Where-Object RecipientTypeDetails -eq "UserMailbox" | Where-Object { $Excluded -notcontains $_.Identity }
foreach ($Bal in $Mailboxes) {
if ($BAL.Languages -like "*FR*") {
$Calendar = Get-MailboxFolderPermission -Identity "$($BAL.PrimarySMTPAddress):\Calendrier" -ErrorAction SilentlyContinue | Select Identity, User, AccessRights
}
else {
$Calendar = Get-MailboxFolderPermission -Identity "$($BAL.PrimarySMTPAddress):\Calendar" -ErrorAction SilentlyContinue | Select Identity, User, AccessRights
}
if ($Calendar.User.DisplayName -notcontains $AuditMailboxe.Identity) {
Write-Host "$($AuditMailboxe.Identity) n'a pas acces au Calendrier de $($Bal.Identity)" -ForegroundColor Yellow
if ($Action -eq "M") {
if ($BAL.Languages -like "*FR*") {
Add-MailboxFolderPermission -Identity ($Bal.Identity + ":\Calendrier") -User $AuditMailboxe.UserPrincipalName -AccessRights Reviewer
}
else {
Add-MailboxFolderPermission -Identity ($Bal.Identity + ":\Calendar") -User $AuditMailboxe.UserPrincipalName -AccessRights Reviewer
}
}
}
else {
Write-Host "$($AuditMailboxe.Identity) a acces au Calendrier de $($Bal.Identity)" -ForegroundColor Green
}
}

View File

@ -0,0 +1 @@
# Exchange Online

View File

@ -0,0 +1,4 @@
Name;alias;username;members
Contact ;contact;contact@hitea.fr;p.dupont@hitea.fr
SAV;sav;sav@hitea.fr;p.dupont@hitea.fr,d.bellier@hitea.fr
Marketing;marketing;marketing@hitea.fr;b.canu@hitea.fr,j.tartas@hitea.fr
1 Name alias username members
2 Contact contact contact@hitea.fr p.dupont@hitea.fr
3 SAV sav sav@hitea.fr p.dupont@hitea.fr,d.bellier@hitea.fr
4 Marketing marketing marketing@hitea.fr b.canu@hitea.fr,j.tartas@hitea.fr

View File

@ -0,0 +1,16 @@
#Il faut installer l'outil AZCopy
#Se rendre dans le repertoire d'AZCopy
cd "C:\Program Files (x86)\Microsoft SDKs\Azure\AzCopy"
#Définir la source des PST
$PSTFile = "\\SRV01\PSTImport"
#Définir l'URL du blob Azure
$AzureStore = "AZ_BLOB_URL"
#Définir le chemin du fichier log
$LogFile = "C:\importPST_log.txt"
#Lancer l'upload vers Azure
& .\AzCopy.exe /Source:$PSTFile /Dest:$AzureStore /V:$LogFile /Y

View File

@ -0,0 +1,45 @@
param ([PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
[string]$Mailbox,
[PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
[string]$StartDate,
[PARAMETER(Mandatory = $TRUE, ValueFromPipeline = $FALSE)]
[string]$EndDate,
[PARAMETER(Mandatory = $FALSE, ValueFromPipeline = $FALSE)]
[string]$Subject,
[PARAMETER(Mandatory = $False, ValueFromPipeline = $FALSE)]
[switch]$IncludeFolderBind,
[PARAMETER(Mandatory = $False, ValueFromPipeline = $FALSE)]
[switch]$ReturnObject)
BEGIN {
[string[]]$LogParameters = @('Operation', 'LogonUserDisplayName', 'LastAccessed', 'DestFolderPathName', 'FolderPathName', 'ClientInfoString', 'ClientIPAddress', 'ClientMachineName', 'ClientProcessName', 'ClientVersion', 'LogonType', 'MailboxResolvedOwnerName', 'OperationResult')
}
END {
if ($ReturnObject)
{ return $SearchResults }
elseif ($SearchResults.count -gt 0) {
$Date = get-date -Format yyMMdd_HHmmss
$OutFileName = "AuditLogResults$Date.csv"
write-host
write-host -fore green "Posting results to file: $OutfileName"
$SearchResults | export-csv $OutFileName -notypeinformation -encoding UTF8 -Delimiter ";"
}
}
PROCESS {
write-host -fore green 'Searching Mailbox Audit Logs...'
$SearchResults = @(search-mailboxAuditLog $Mailbox -StartDate $StartDate -EndDate $EndDate -LogonTypes Owner, Admin, Delegate -ShowDetails -resultsize 50000)
write-host -fore green '$($SearchREsults.Count) Total entries Found'
if (-not $IncludeFolderBind) {
write-host -fore green 'Removing FolderBind operations.'
$SearchResults = @($SearchResults | ? { $_.Operation -notlike 'FolderBind' })
write-host -fore green 'Filtered to $($SearchREsults.Count) Entries'
}
$SearchResults = @($SearchResults | select ($LogParameters + @{Name = 'Subject'; e = { if (($_.SourceItems.Count -eq 0) -or ($_.SourceItems.Count -eq $null)) { $_.ItemSubject } else { ($_.SourceItems[0].SourceItemSubject).TrimStart(' ') } } },
@{Name = 'CrossMailboxOp'; e = { if (@('SendAs', 'Create', 'Update') -contains $_.Operation) { 'N/A' } else { $_.CrossMailboxOperation } } }))
$LogParameters = @('Subject') + $LogParameters + @('CrossMailboxOp')
If ($Subject -ne '' -and $Subject -ne $null) {
write-host -fore green 'Searching for Subject: $Subject'
$SearchResults = @($SearchResults | ? { $_.Subject -match $Subject -or $_.Subject -eq $Subject })
write-host -fore green 'Filtered to $($SearchREsults.Count) Entries'
}
$SearchResults = @($SearchResults | select $LogParameters)
}