0

This is directed towards Exchange/Office 365 powershell but can apply for other types as well.

If i have a list of users for example, and I use UserPrincipalName for their identity - now in all my scripts I can pull data using UserPrincipalName for the identity, but in most UserPrincipalName isn't actually an exportable value. So, if you take my two examples below I can pull data in both using UserPrincipalName for the identity, but in the 2nd one the ouput would be blank.

How can I insert for example the identity value UserPrincipalName into the 2nd. This would apply for more than the two scripts mentioned below.

$CSV |  foreach {
  Get-Mailbox -resultsize unlimited -Identity $_.UserPrincipalName
} | select userprincipalname, server |out-gridview

Example output:

UPN@something.com, server101

$csv | ForEach {
  Get-ActiveSyncDeviceStatistics -Identity:$_.UserPrincipalName
} | select  DeviceFriendlyName,UserPrincipalName |out-gridview 

Example output:

2nd: DeviceIOS4,-

Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328

1 Answers1

0

I don't have an Exchange at hand, but most likely the objects returned by Get-Mailbox do have a UserPrincipalName property, while the objects returned by Get-ActiveSyncDeviceStatistics don't. To preserve the UPN in the output of the second script, you can do something like this:

$csv | ForEach {
  $upn = $_.UserPrincipalName
  Get-ActiveSyncDeviceStatistics -Identity:$upn
} | select  DeviceFriendlyName,@{n='UserPrincipalName';e={$upn}} |out-gridview 
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328