How to get the list of Office 365 licenced users from a specific Active Directory group?

Could you please tell how to get the list of all/unlicensed/licensed users from a specific Active Directory group? I’m guessing that I need to pipe ‘Get-MsolGroupMember’ to (or vice versa) ‘Get-MsolUser’ to get the list of all users from AD group?

Additional request, if the user in AD group Office 365 licensed already I would like to know subscriptions and which services within that subscription he/she can use?    

Thanks
LVL 1
OlevoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Vasil Michev (MVP)Commented:
It's best to compare the objects directly, as you might have some cases for which the on-prem user is not synced to the cloud, or the UPNs dont match, etc. Load both the AD and WAAD modules, expand the group membership and for each member get the licensing info from WAAD.

The below will give you status on the individual service:

(Get-MsolUser -UserPrincipalName user@domain.com).licenses.servicestatus

Open in new window


There's a sample script here, just add the AD part: https://gallery.technet.microsoft.com/scriptcenter/Export-a-Licence-b200ca2a

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Office 365

From novice to tech pro — start learning today.