Please kindly note that our forum doesn't support scripting requests.
If you need some suggestions for your script, I would recommend adding the windows-server-powershell to the scripting question in order to get better support.
Thanks for your understanding.
Would the following script work for you?
$report = @()
$Users = Import-CSV c:\temp\inbox.csv
foreach($User in $Users)
{
$x = Get-Mailbox $User.PrimarySMTPAddress
$y = Get-MailboxStatistics $User.PrimarySMTPAddress
$report += New-Object PSObject -Property $([ordered]@{
"UserPrincipalName" = $x.UserPrincipalName
"MailboxSize" = $y.TotalItemSize
"MailboxItemCount" = $y.ItemCount
"MailboxUsageLocation" =$x.Usagelocation
})
}
$report | export-csv c:\temp\result.csv
In my input.csv file I am using PrimarySMTPAddress as the filter for mailbox identity.
You may modify this part if you would like to use other attributes.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.