additional info to be able to filter the sheet by country<\/li>\n<\/ul>\nI tried this command (I know, there are more parameters for test only) and almost everything is there except \nget-mailbox | select-object displayname, SamAccountName, database, WhenMailboxCreated, OrganizationalUnit, EmailAddresses, GrantSendOnBehalfTo, HiddenFromAddressListsEnabled, PrimarySmtpAddress, RecipientType, RecipientTypeDetails |export-csv -path d:_temp\\SG1.csv<\/p>\n
EmailAddresses returns “Microsoft.Exchange.Data.ProxyAddressCollection” \nGrantSendOnBehalfTo returns “Microsoft.Exchange.Data.Directory.ADMultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]” \nI don’t how to include user country into this export.<\/p>","upvoteCount":5,"datePublished":"2011-08-12T06:39:27.000Z","url":"https://community.spiceworks.com/t/list-of-all-mailboxes-on-exchange-2010-sp1/98542/1","author":{"@type":"Person","name":"haldo987644","url":"https://community.spiceworks.com/u/haldo987644"}},{"@type":"Answer","text":"
Here what I use on a server basis<\/p>\n
Get-MailboxServer -Identity | Get-MailboxStatistics | select-object servername, databasename, DisplayName, @{expression={$_.TotalItemSize.Value.ToMB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount | export-csv c:\\exchangeuserstats.csv<\/p>","upvoteCount":2,"datePublished":"2011-08-12T06:45:07.000Z","url":"https://community.spiceworks.com/t/list-of-all-mailboxes-on-exchange-2010-sp1/98542/2","author":{"@type":"Person","name":"ben","url":"https://community.spiceworks.com/u/ben"}},{"@type":"Answer","text":"
Which I totally ripped off from anther thread!<\/p>","upvoteCount":0,"datePublished":"2011-08-12T06:46:16.000Z","url":"https://community.spiceworks.com/t/list-of-all-mailboxes-on-exchange-2010-sp1/98542/3","author":{"@type":"Person","name":"ben","url":"https://community.spiceworks.com/u/ben"}},{"@type":"Answer","text":"
It’s some time but I finally managed to look on this request again. I slightly modified your script to have better output and to work without the Quest snap in. It’s freeware but still, this way it’s not necessary to install the files.<\/p>\n
$OutFile = “D:_temp\\SG1.txt” \ndel $outfile \nAdd-Content -Path $OutFile -Value “Lastname~Firstname~SamAccountName~database~WhenMailboxCreated~OrganizationalUnit~GrantSendOnBehalfTo~HiddenFromAddressListsEnabled~PrimarySmtpAddress~RecipientType~RecipientTypeDetails~Country~EmailAddresses~LastLogonTime” \n$users = get-mailbox -resultsize unlimited \nforeach ($User in $users){ \n$UserInfo = get-user $user.samaccountname \n$UserMail = get-mailbox $user.samaccountname \n$UserStat = get-mailboxStatistics $user.samaccountname \n$Outinfo = $UserInfo.Lastname +“~”+ $UserInfo.Firstname +“~”+ $UserMail.SamAccountName +“~”+ $UserMail.database +“~”+ $UserMail.WhenMailboxCreated +“~”+ $UserMail.OrganizationalUnit +“~”+ $UserMail.GrantSendOnBehalfTo +“~”+ $UserMail.HiddenFromAddressListsEnabled +“~”+ $UserMail.PrimarySmtpAddress +“~”+ $UserMail.RecipientType +“~”+ $UserMail.RecipientTypeDetails +“~”+ $UserInfo.CountryOrRegion +“~”+ $UserMail.EmailAddresses +“~”+ $UserStat.LastLogonTime \nadd-content -Value $Outinfo -Path $OutFile \n}<\/p>","upvoteCount":2,"datePublished":"2011-10-10T17:34:16.000Z","url":"https://community.spiceworks.com/t/list-of-all-mailboxes-on-exchange-2010-sp1/98542/5","author":{"@type":"Person","name":"haldo987644","url":"https://community.spiceworks.com/u/haldo987644"}},{"@type":"Answer","text":"
Great post… Thanks for that author.<\/p>\n
Modified it a bit to get user’s personal archive status. Hopefully this be help to someone too.<\/p>\n
$OutFile = “E:\\Temp\\SG1.txt” \ndel $outfile \nAdd-Content -Path $OutFile -Value “SamAccountName PrimarySmtpAddress ItemCount ItemSize” \n$users = get-mailbox -resultsize unlimited \nforeach ($User in $users){ \n$UserInfo = get-user $user.samaccountname \n$UserMail = get-mailbox $user.samaccountname \n$UserStat = get-mailboxStatistics $user.samaccountname -archive \n$Outinfo = $UserMail.SamAccountName \" \" $UserMail.PrimarySmtpAddress \" \" $UserStat.ItemCount \" \" $UserStat.TotalItemSize \nadd-content -Value $Outinfo -Path $OutFile \n}<\/p>","upvoteCount":1,"datePublished":"2017-01-18T02:49:19.000Z","url":"https://community.spiceworks.com/t/list-of-all-mailboxes-on-exchange-2010-sp1/98542/6","author":{"@type":"Person","name":"lakshmibalaramane","url":"https://community.spiceworks.com/u/lakshmibalaramane"}}]}}
I’m looking for a way to list all mailboxes and save it as excel sheet. What I need to list is
user id’s and their mailboxes
group id’s and their mailboxes
additional info to be able to filter the sheet by country
I tried this command (I know, there are more parameters for test only) and almost everything is there except
get-mailbox | select-object displayname, SamAccountName, database, WhenMailboxCreated, OrganizationalUnit, EmailAddresses, GrantSendOnBehalfTo, HiddenFromAddressListsEnabled, PrimarySmtpAddress, RecipientType, RecipientTypeDetails |export-csv -path d:_temp\SG1.csv
EmailAddresses returns “Microsoft.Exchange.Data.ProxyAddressCollection”
GrantSendOnBehalfTo returns “Microsoft.Exchange.Data.Directory.ADMultiValuedProperty`1[Microsoft.Exchange.Data.Directory.ADObjectId]”
I don’t how to include user country into this export.
5 Spice ups
ben
(Hubba Bubba)
August 12, 2011, 6:45am
2
Here what I use on a server basis
Get-MailboxServer -Identity | Get-MailboxStatistics | select-object servername, databasename, DisplayName, @{expression={$_.TotalItemSize.Value.ToMB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount | export-csv c:\exchangeuserstats.csv
2 Spice ups
ben
(Hubba Bubba)
August 12, 2011, 6:46am
3
Which I totally ripped off from anther thread!
Try the following, the one big problem with CSVs and some of the fields you’re collecting data from are that the Display name, email addresses and send on behalf fields are comma separated. I export it to a txt file, you can then open it using Excel and use the ~ character as you separator and it’s work for you. This requires Quests ad tools for powershell in addition to the exchange tools, but worked great on my system.
Add-PSSnapin Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue
$OutFile = “C:\SG1.txt”
del $outfile
Add-Content -Path $OutFile -Value “Lastname~Firstname~SamAccountName~database~WhenMailboxCreated~OrganizationalUnit~GrantSendOnBehalfTo~HiddenFromAddressListsEnabled~PrimarySmtpAddress~RecipientType~RecipientTypeDetails~Country~EmailAddresses”
$users = get-qaduser -sizelimit 0 -includedProperties lastname~firstname~samaccountname~co~email | where {$_.email -ne $null}
foreach ($User in $users){
$Country = $user.co
$UserMail = get-mailbox $user.samaccountname
$Outinfo = $User.Lastname +“~”+ $User.Firstname +“~”+ $UserMail.SamAccountName +“~”+ $UserMail.database +“~”+ $UserMail.WhenMailboxCreated +“~”+ $UserMail.OrganizationalUnit +“~”+ $UserMail.GrantSendOnBehalfTo +“~”+ $UserMail.HiddenFromAddressListsEnabled +“~”+ $UserMail.PrimarySmtpAddress +“~”+ $UserMail.RecipientType +“~”+ $UserMail.RecipientTypeDetails +“~”+ $Country +“~”+ $UserMail.EmailAddresses
add-content -Value $Outinfo -Path $OutFile
}
1 Spice up
It’s some time but I finally managed to look on this request again. I slightly modified your script to have better output and to work without the Quest snap in. It’s freeware but still, this way it’s not necessary to install the files.
$OutFile = “D:_temp\SG1.txt”
del $outfile
Add-Content -Path $OutFile -Value “Lastname~Firstname~SamAccountName~database~WhenMailboxCreated~OrganizationalUnit~GrantSendOnBehalfTo~HiddenFromAddressListsEnabled~PrimarySmtpAddress~RecipientType~RecipientTypeDetails~Country~EmailAddresses~LastLogonTime”
$users = get-mailbox -resultsize unlimited
foreach ($User in $users){
$UserInfo = get-user $user.samaccountname
$UserMail = get-mailbox $user.samaccountname
$UserStat = get-mailboxStatistics $user.samaccountname
$Outinfo = $UserInfo.Lastname +“~”+ $UserInfo.Firstname +“~”+ $UserMail.SamAccountName +“~”+ $UserMail.database +“~”+ $UserMail.WhenMailboxCreated +“~”+ $UserMail.OrganizationalUnit +“~”+ $UserMail.GrantSendOnBehalfTo +“~”+ $UserMail.HiddenFromAddressListsEnabled +“~”+ $UserMail.PrimarySmtpAddress +“~”+ $UserMail.RecipientType +“~”+ $UserMail.RecipientTypeDetails +“~”+ $UserInfo.CountryOrRegion +“~”+ $UserMail.EmailAddresses +“~”+ $UserStat.LastLogonTime
add-content -Value $Outinfo -Path $OutFile
}
2 Spice ups
Great post… Thanks for that author.
Modified it a bit to get user’s personal archive status. Hopefully this be help to someone too.
$OutFile = “E:\Temp\SG1.txt”
del $outfile
Add-Content -Path $OutFile -Value “SamAccountName PrimarySmtpAddress ItemCount ItemSize”
$users = get-mailbox -resultsize unlimited
foreach ($User in $users){
$UserInfo = get-user $user.samaccountname
$UserMail = get-mailbox $user.samaccountname
$UserStat = get-mailboxStatistics $user.samaccountname -archive
$Outinfo = $UserMail.SamAccountName " " $UserMail.PrimarySmtpAddress " " $UserStat.ItemCount " " $UserStat.TotalItemSize
add-content -Value $Outinfo -Path $OutFile
}
1 Spice up