Compare commits
2 Commits
058108fbc9
...
ef2f17cadb
Author | SHA1 | Date | |
---|---|---|---|
nicolas | ef2f17cadb | ||
nicolas | a9fd6cec2d |
|
@ -0,0 +1,55 @@
|
||||||
|
Add-PSSnapin Microsoft.Exchange.Management.Powershell.E2010
|
||||||
|
$domaines = get-accepteddomain
|
||||||
|
$nomduserveur = "Entrez le nom de votre serveur"
|
||||||
|
$expediteur = "Adresse expediteur du rapport par mail"
|
||||||
|
$destinataire = "Adresse destinataire du rapport par mail"
|
||||||
|
$smtpserver = "Entrez le nom du serveur smtp qui enverra le mail"
|
||||||
|
$boites = Get-Mailbox -Server $nomduserveur
|
||||||
|
$tableau = @()
|
||||||
|
$chemin = [Environment]::GetFolderPath("Desktop")
|
||||||
|
$code = [System.Text.Encoding]::Utf8
|
||||||
|
|
||||||
|
foreach ($boite in $boites)
|
||||||
|
{
|
||||||
|
$statsboite = Get-MailboxStatistics $boite
|
||||||
|
$statsboite |ft
|
||||||
|
$ajout = New-Object PSObject
|
||||||
|
#$domaineboite = get-mailbox $statsboite.displayname
|
||||||
|
$domaineboite = ($boite.primarysmtpaddress).domain
|
||||||
|
Clear-Variable taille -ErrorAction silentlycontinue
|
||||||
|
$taille = $statsboite.TotalItemSize.Value.ToMB()
|
||||||
|
|
||||||
|
if ($taille -ne $null)
|
||||||
|
{
|
||||||
|
$ajout | Add-Member -MemberType Noteproperty -Name "Nom" -Value $statsboite.displayname
|
||||||
|
$ajout | Add-Member -MemberType Noteproperty -Name "Domaine" -Value $domaineboite
|
||||||
|
$ajout | Add-Member -MemberType Noteproperty -Name "Taille (en Mb)" -Value $taille
|
||||||
|
$tableau += $ajout
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
set-location c:\
|
||||||
|
$fichiers = @()
|
||||||
|
Foreach ($domaine in $domaines)
|
||||||
|
{
|
||||||
|
$tableauclient = $tableau | Where-Object {$_.domaine -eq $domaine.domainname}
|
||||||
|
$tableauclient = $tableauclient |Sort-Object -Property "Taille (en Mb)" -Descending
|
||||||
|
if ($tableauclient -ne $null)
|
||||||
|
{
|
||||||
|
$filename = ($domaine.name) +" " +(get-date).toshortdatestring().replace("/","_")
|
||||||
|
$repertoire = ($chemin+"\Export\"+($domaine.name))
|
||||||
|
$fichier = ($repertoire+"\"+$filename)+".csv"
|
||||||
|
if ((Test-Path $repertoire) -eq $false){ New-Item -ItemType directory -Path $repertoire}
|
||||||
|
|
||||||
|
$tableauclient | Export-csv -encoding UTF8 -Path $fichier -NoTypeInformation -Force -Delimiter ";"
|
||||||
|
$date = get-date
|
||||||
|
$body = "Export des données le " + $date
|
||||||
|
$fichiers += $fichier
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$fichiers = $fichiers |sort-object
|
||||||
|
Send-MailMessage -Subject "Export $date" -Attachments $fichiers -Body $body -Encoding $code -From $expediteur -To $destinataire -SmtpServer $smtpserver
|
Loading…
Reference in New Issue
Block a user