Forum Discussion

Zeff Wheelock's avatar
Zeff Wheelock
Iron Contributor
Feb 28, 2018

Get-MobileDeviceStatistics Issue

Greetings,

 

Can someone explain if I do a:

Get-Mailbox -Identity joeSmith@domain.com I get a result

Get-MobileDeviceStatistics -mailbox joesmith@domain.com I get a result

but

Get-Mailbox -Identity joesmith@domain.com | Get-MobileDeviceStatistics -mailbox $_.userprincipalname I get an error?

 

Cannot validate argument on parameter 'Mailbox'. The argument is null or empty. Provide an argument that is not null or empty, and
then try the command again.
+ CategoryInfo : InvalidData: (:) [Get-MobileDeviceStatistics], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Get-MobileDeviceStatistics
+ PSComputerName : ps.outlook.com

 

I have tried -Mailbox $_ and -Mailbox:$_ also.

  • You are not using the correct syntax. Try this:

     

    Get-Mailbox vasil | % { Get-MobileDeviceStatistics -Mailbox $_.UserPrincipalName }
    • Zeff Wheelock's avatar
      Zeff Wheelock
      Iron Contributor

      Ah!  So you do need a foreach statement even though you are only pulling one object.  Makes.... sense.... I guess.  Me, being logical (my fault), would have thought foreach would loop 2 or more objects.  Silly me.

Resources