Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Office 365--Powershell Script needed to find all users with a certain UPN

Posted on 2014-11-07
2
Medium Priority
?
7,427 Views
Last Modified: 2014-11-07
Powershell Script needed to find all users with a certain UPN ending in @domain.org in my 365 Tenant. What query or filter can i use with Get-MSolUser -All ?

This one doens't work:

  Get-MSoluser -All |? {$_.IsLicensed -match 'False' -and $_.UserPrincipalName -match '*@domain.org'}
0
Comment
Question by:Anthony K O365
2 Comments
 
LVL 13

Accepted Solution

by:
lciprianionut earned 2000 total points
ID: 40428482
Did you tried Get-MSoluser -All -DomainName "domain.org" |? {-not $_.IsLicensed}
Also this should work Get-MSoluser -All |? {-not $_.IsLicensed -and $_.UserPrincipalName -like "*@domain.org"}
0
 

Author Closing Comment

by:Anthony K O365
ID: 40428638
Excellent! Worked as expected.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Loops Section Overview

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question