Author Posts

August 18, 2016 at 7:32 pm

I need to pull from O365 the following information for each licensed user; I am having difficulty finding the syntax to get CustomAttributes from MailBox. Any suggestions?

From Get-MsolUser
UserPrincipalName
DisplayName
FirstName
LastName
Department
Office
Licenses Account SkuId

From Get-Mailbox
CustomAttribute 11

Here is the scrip I run that gets the user info. How can I add to the script to get the CustomAttribute 11 added the csv file?

Get-MsolUser –all | Where-Object { $_.isLicensed -eq "TRUE" } | Select-Object UserPrincipalName, DisplayName, FirstName, LastName, Department, Office, {$_.Licenses.AccountSkuId} | Export-Csv c:\zip\201607LicensedUsers.csv -NoTypeInformation

August 18, 2016 at 8:30 pm

This is how you combine objects. replace mailboxmoveremotehostname with the property you want, I just picked one at random that is populated.

get-msoluser -UserPrincipalName 'upn@somewhere.com' | select userprincipalname,displayname,islicensed,@{n='exonline';e={(Get-Mailbox $_.userprincipalname).MailboxMoveRemoteHostName}}

  • This reply was modified 2 years, 1 month ago by  Dan Potter.

August 18, 2016 at 8:40 pm

In long form it would look something like this.

$msolusers = Get-MsolUser –all | Where-Object { $_.isLicensed -eq "TRUE" }

foreach($user in $msolusers){

$exchangestuff = (Get-Mailbox $user.userprincipalname).MailboxMoveRemoteHostName

[pscustomobject]@{

upn = $user.userprincipalname
exchangestuff = $exchangestuff
#etc..


}


}