Compare commits
No commits in common. "ef2f17cadb56e739db1542964d7d175345361901" and "058108fbc93ba4082333ce10afbd8ee7a3ed5771" have entirely different histories.
ef2f17cadb
...
058108fbc9
|
@ -1,55 +0,0 @@
|
|||
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