ndalmolin_13
asked on
Help getting mailbox size for a group of users using Powershell
Greetings Powershell Gurus,
I have a list of users that I generated with the following command:
Get-qaduser –department sales | select-Object logonname
The list of users looks like the following:
LogonName
---------
emusta
sbrown
cflynn
psnider
mpalacios
jgrubb
jfergen
dkiewit
I would like to now find the mailbox size for these users. I know that I’m going to use the get-mailboxstatistics commandlet. I thought the following would work:
$Users = Get-qaduser –department facilities | select-Object logonname
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user -Server mail01}
When I run the command above, I get the following error that I’m having trouble working through:
Get-MailboxStatistics : Cannot bind parameter 'Identity'. Cannot convert the "@{LogonName=emusta}" value of type "Selected.Quest.ActiveRole s.ArsPow
erShellSnapIn.Data.ArsUser Object" to type "Microsoft.Exchange.Config uration.Ta sks.Genera lMailboxId Parameter" .
At line:3 char:59
+ foreach ($User in $Users) {Get-MailboxStatistics -Identity <<<< $user -Server mail01}
+ CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes sage,Micro soft.Excha nge.Manage ment.MapiT asks.GetMa ilboxStati stics
Any ideas on what I’m doing wrong here. Any help would be greatly appreciated.
Thanks,
Nick
I have a list of users that I generated with the following command:
Get-qaduser –department sales | select-Object logonname
The list of users looks like the following:
LogonName
---------
emusta
sbrown
cflynn
psnider
mpalacios
jgrubb
jfergen
dkiewit
I would like to now find the mailbox size for these users. I know that I’m going to use the get-mailboxstatistics commandlet. I thought the following would work:
$Users = Get-qaduser –department facilities | select-Object logonname
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user -Server mail01}
When I run the command above, I get the following error that I’m having trouble working through:
Get-MailboxStatistics : Cannot bind parameter 'Identity'. Cannot convert the "@{LogonName=emusta}" value of type "Selected.Quest.ActiveRole
erShellSnapIn.Data.ArsUser
At line:3 char:59
+ foreach ($User in $Users) {Get-MailboxStatistics -Identity <<<< $user -Server mail01}
+ CategoryInfo : InvalidArgument: (:) [Get-MailboxStatistics], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMes
Any ideas on what I’m doing wrong here. Any help would be greatly appreciated.
Thanks,
Nick
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
If you are not restricted to use just the logonname, You can use it this way with displayname or primarysmtpaddress,
$Users = Get-qaduser –department facilities
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user.displayname -Server mail01}
$Users = Get-qaduser –department facilities
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user.primarysmtpaddress -Server mail01}
$Users = Get-qaduser –department facilities
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user.displayname -Server mail01}
$Users = Get-qaduser –department facilities
foreach ($User in $Users) {Get-MailboxStatistics -Identity $user.primarysmtpaddress -Server mail01}
Open in new window