add script

This commit is contained in:
2025-08-06 10:35:05 +02:00
parent b78e202f58
commit ef09f0b350
229 changed files with 264140 additions and 1 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
Set-mailbox $User.Identity -UseDatabaseQuotaDefaults $true -ProhibitSendReceiveQuota 'Unlimited' -ProhibitSendQuota 'unlimited' -CalendarLoggingQuota 1GB

View File

@@ -0,0 +1,50 @@
add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$Date = Get-Date -format 'yyyy-MM-dd HH-mm-ss'
$Fichier = "D:\Informatique\All-Mailbox-$Date.csv"
$emailAttachments = "D:\Informatique\All-Mailbox.csv"
#Get-Mailbox -ResultSize Unlimited | Select-Object Displayname,name,alias,PrimarySmtpAddress,Database,@{Name='TotalItemSize'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota | where-object {$_.enabled -eq $True} | export-csv -path $Fichier
Get-Mailbox -ResultSize Unlimited | Select-Object Displayname,name,alias,PrimarySmtpAddress,Database,@{Name='TotalItemSize'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).TotalItemSize))}},@{Name='ItemCount'; Expression={[String]::join(";",((Get-MailboxStatistics -identity $_.identity).ItemCount))}},IssueWarningQuota, ProhibitSendQuota, ProhibitSendReceiveQuota | export-csv -path $Fichier
$SPLA = (Get-Mailbox -ResultSize Unlimited -Filter {EmailAddresses -like "*.mailnot.fr"} ).Count
(Get-Content $Fichier) -replace '","','";"' | Set-Content "D:\Informatique\All-Mailbox-temp.csv"
(Get-Content "D:\Informatique\All-Mailbox-temp.csv") -replace ',,,',';;;' | Set-Content $emailAttachments
Start-Sleep -s 10
$emailSmtpServer = "10.101.10.2"
$emailSmtpServerPort = "25"
$emailFrom = "Rapports@cloud-fichorga.fr"
$emailTo = "hcornet@fichorga.fr, ypereira@fichorga.fr, fdupont@fichorga.fr, cleroux@fichorga.fr, jmdefossez@fichorga.fr, alefevre@pmsjuris.fr, sdemarez@fichorga.fr, mdelplanche@fichorga.fr, eringuet@fichorga.fr"
$body = "<HTML><HEAD><META http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" /><TITLE></TITLE></HEAD>"
$body += "<BODY bgcolor=""#FFFFFF"" style=""font-size: Small; font-family: TAHOMA; color: #000000""><P>"
$body += "Bonjour <b><font color=blue>a tous</b></font><br><br>"
$body += "Voici l'extraction de l'ensemble des boites mail client a la date du <b>$Date</b>.<br>"
$body += "<br><br>"
$body += "Il y a : <b><font color=blue>$SPLA</b></font> comptes à déclarer pour le SPLA.<br>"
$body += "<br><br>"
$body += "Bonne lecture.<br><br>"
$body += "<b><font color=red>Merci de ne pas faire repondre a ce message.</b></font><br>"
$body += "Pour ne plus faire partie de la liste <a href='mailto:hcornet@fichorga.fr?Subject=Desinscription%20Rapport%20mail' target='_top'>Send Mail</a>.<br>"
$emailMessage = New-Object System.Net.Mail.MailMessage( $emailFrom , $emailTo )
$emailMessage.Subject = "Extraction : client CONNECT"
$emailMessage.IsBodyHtml = $True
$emailMessage.Body = $body
$emailMessage.Attachments.add($emailAttachments)
$SMTPClient = New-Object System.Net.Mail.SmtpClient( $emailSmtpServer, $emailSmtpServerPort )
$SMTPClient.EnableSsl = $False
$SMTPClient.Send( $emailMessage )
Start-Sleep -s 10
Remove-Item "D:\Informatique\All-Mailbox-$Date.csv" -recurse
Remove-Item "D:\Informatique\All-Mailbox-temp.csv" -recurse
Remove-Item "D:\Informatique\All-Mailbox.csv" -recurse

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,2 @@
Add-MailboxFolderPermission -Identity BAL@DOMAINE:\calendrier -AccessRights Editor -user <USER>

View File

@@ -0,0 +1,2 @@
Remove-MailboxFolderPermission -Identity BAL@DOMAINE:\calendrier -user <USER>

View File

@@ -0,0 +1,2 @@
Set-MailboxAutoReplyConfiguration <USER> -AutoReplyState enabled -ExternalAudience all -InternalMessage "MESSAGE" ExternalMessage "MESSAGE"

1
Exchange/purge.ps1 Normal file
View File

@@ -0,0 +1 @@
Get-ChildItem 'C:\Inetpub\Logs' -Directory | Get-ChildItem -Include '*.log' -Recurse | ? LastWriteTime -lt (Get-Date).AddDays(-20) | Remove-Item

View File

@@ -0,0 +1,5 @@
$sessionOption = New-PsSessionOption -SkipCACheck -SkipCNCheck -SkipRevocationCheck
$credential = $host.ui.PromptForCredential("Connexion Exchange 2013", "Merci de renseigner votre compte.","DOMAINE\UTILISATEUR","NetBiosUserName")
$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri "http://DOMAINE/powershell" -Credential $Credential -Authentication kerberos
Import-PSSession $session

4
Exchange/scheduler.ps1 Normal file
View File

@@ -0,0 +1,4 @@
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "hcornet@fichorga.fr" -MailServer 10.101.10.2
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "jmdefossez@fichorga.fr" -MailServer 10.101.10.2
.\ExchangeEnvironmentReport.ps1 -HTMLReport .\report.html -SendMail $True -MailFrom "Rapports@cloud-fichorga.fr" -MailTo "alefevre@pmsjuris.fr" -MailServer 10.101.10.2
.\Test-ExchangeServerHealth.ps1 -ReportMode -SendEmail

110
Exchange/status-backup.ps1 Normal file
View File

@@ -0,0 +1,110 @@
param($action) # paramètre à scpécifier lors de l'appel
$Run_Path=Split-Path -parent $MyInvocation.MyCommand.Definition
$ErrorActionPreference = "Stop"
$resultlog="$Run_Path\Checkbackup.log"
<# Log
------------------------------------------------
Usage : Utilisé pour logger
$data : Informations à logger
$new : A préciser pour démarrer un nouveau log.
#>
Function Log ($data,$new) {
If ($new) {
write-output "$data" | Out-File $resultlog
}
Else {
write-output "$data" | Out-File $resultlog -Append
}
}
Log "################# START ###############" $true
Try {
add-pssnapin Microsoft.Exchange.Management.PowerShell.SnapIn
}
Catch {
}
$global:ErrorCopy=@();$global:ErrorFull=@();$global:ErrorIncr=@()
$listdb=Get-MailboxDatabase -Status | select name, Server, LastFullBackup, LastIncrementalBackup, LastCopyBackup
Foreach ($db in $listdb) {
#Log $db
If(! $db.Name.Contains("Mailbox")) {
Switch ($action) {
"COPY" {
If (! $db.LastCopyBackup) {
$global:ErrorIncr+=$db.Name
}
Else {
If (($(Get-Date) - $db.LastCopyBackup).TotalMinutes -gt 35) {
$global:ErrorCopy+=$db.Name
}
}
}
"FULL" {
If (! $db.LastFullBackup) {
$global:ErrorIncr+=$db.Name
}
Else {
If (($(Get-Date) - $db.LastFullBackup).TotalDays -gt 7) {
$global:ErrorFull+=$db.Name
}
}
}
"INC" {
If (! $db.LastIncrementalBackup) {
If (! $db.LastFullBackup) {
$global:ErrorIncr+=$db.Name
}
Elseif(($(Get-Date) - $db.LastFullBackup).TotalDays -gt 1) {
$global:ErrorIncr+=$db.Name
}
}
Elseif(($(Get-Date) - $db.LastIncrementalBackup).TotalDays -gt 1) {
If (! $db.LastFullBackup)
{
$global:ErrorIncr+=$db.Name
}
Elseif(($(Get-Date) - $db.LastFullBackup).TotalDays -gt 1) {
$global:ErrorIncr+=$db.Name
}
}
}
}
}
}
If ($ErrorCopy.count -gt 0) {
$string="Error on "
$ErrorCopy=$ErrorCopy | sort
Foreach ($dbname in $ErrorCopy) {
$string+=$dbname+","
}
$string+=" during CopyBackup(Appsync)"
Log $string;$string;exit 2
}
If ($ErrorFull.count -gt 0) {
$string="Error on "
$ErrorFull=$ErrorFull | sort
Foreach ($dbname in $ErrorFull) {
$string+=$dbname+","
}
$string+=" during FullBackup(TSM)"
Log $string;$string;exit 2
}
If ($ErrorIncr.count -gt 0) {
$string="Error on "
$ErrorIncr=$ErrorIncr | sort
Foreach ($dbname in $ErrorIncr) {
$string+=$dbname+","
}
$string+=" during IncBackup(TSM)"
Log $string;$string;exit 2
}
Log "################## END ####################"

2
Exchange/status-sync.ps1 Normal file
View File

@@ -0,0 +1,2 @@
Get-ExchangeServer | Where-Object {$_.IsHubTransportServer -eq $True} | Get-Queue | ft Identity, NextHopDomain, MessageCount

View File

@@ -0,0 +1,2 @@
Get-MailboxAutoReplyConfiguration <USER>