Hi experts please help me with powershell script.
I want to export my mailboxes for whom archive mailboxes are enabled or disabled, if enabled i require to export below info to csv file
Archive Warning Quota,
ArchiveQuota
and how much its used and database on which this archive mailbox resides.

7 Spice ups

This should do what you’re after!

$DataPath = “C:\Archiving-Quotas.csv”
$Results =@()
$Users = Get-Mailbox
ForEach ($User in $Users)
{
$Data = Get-Mailbox -Identity $User.Alias
$Data | ft Name,Archive
If ($Data.ArchiveStatus -eq $true)
{
$Archiving = “Enabled”
$Quota = $Data.ArchiveQuota
$Warning = $Data.ArchiveWarningQuota
}
Else
{
$Archiving = “Disabled”
$Quota = “Disabled”
$Warning = “Disabled”
}
$TableResults = @{
Archiving = $Archiving
Warning = $Warning
Quota = $Quota
Name = $User.Alias
}
$Results += New-Object psobject -Property $TableResults
}
$Results | Export-CSV -Path $DataPath

Just realised I’ve missed the last 2 parts you wanted. That’ll be difficult for me to test as we don’t have archiving on at all but I’ll give it a go. In the meantime that script should give you a lot of what you need.

Ok here it is but without the usage, I can’t test that part unfortunately though I would assume it could be achieved with Get-MailboxStatistics

$DataPath = “C:\Archiving-Quotas.csv”
$Results =@()
$Users = Get-Mailbox
ForEach ($User in $Users)
{
$Data = Get-Mailbox -Identity $User.Alias
$Data | ft Name,Archive
If ($Data.ArchiveStatus -eq $true)
{
$Archiving = “Enabled”
$Quota = $Data.ArchiveQuota
$Warning = $Data.ArchiveWarningQuota
$Database = $Data.ArchiveDatabase
}
Else
{
$Archiving = “Disabled”
$Quota = $Data.ArchiveQuota
$Warning = $Data.ArchiveWarningQuota
$Database = $Data.ArchiveDatabase
}
$TableResults = @{
Archiving = $Archiving
Warning = $Warning
Quota = $Quota
Database = $Database
Name = $User.Alias
}
$Results += New-Object psobject -Property $TableResults
}
$Results | Export-CSV -Path $DataPath

1 Spice up

Hi,

If you only need archive mailbox information, you could try this:

Get-Mailbox | where {$_.ArchiveDatabase -ne $null} | 
select name, archivedatabase, archivequota, archivewarningquota,
@{label="TotalItemSize(MB)";expression={(Get-MailboxStatistics $_).TotalItemSize.Value.ToMB()}} | 
export-csv c:\archiveuser.csv -append -Notype -Encoding UTF8

It should help to accomplish your job.