Using Powershell to show users in O365 who do not have an ATP license (question)

%3CLINGO-SUB%20id%3D%22lingo-sub-1601217%22%20slang%3D%22en-US%22%3EUsing%20Powershell%20to%20show%20users%20in%20O365%20who%20do%20not%20have%20an%20ATP%20license%20(question)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1601217%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20All%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%20%26nbsp%3BWe%20are%20trying%20to%20script%20a%20way%20to%20show%20users%20in%20Exchange%20Online%20who%20do%20not%20have%20an%20ATP%20license%20attached%20to%20them.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20found%20this%20script%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EGet-MsolUser%20-All%20%7C%20Where-Object%20%7B%24_.licenses%20-ne%20'ATP_ENTERPRISE'%7D%20%7C%20Select-Object%20userprincipalname%2Clicenses%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHowever%2C%20I%20am%20trying%20to%20find%20a%20script%20that%20displays%20only%20users%20that%20do%20not%20have%20an%20ATP%20license%20so%20that%20we%20can%20quickly%20find%20them.%26nbsp%3B%20The%20above%20script%20displays%20all%20users%20and%20their%20licenses%20(including%20those%20that%20do%20not%20have%20an%20ATP%20license)%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20image-alt%3D%22ATPPS.PNG%22%20style%3D%22width%3A%20821px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F213459i8BCC84C564A547A4%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22ATPPS.PNG%22%20alt%3D%22ATPPS.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThx%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1601217%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1602826%22%20slang%3D%22en-US%22%3ERe%3A%20Using%20Powershell%20to%20show%20users%20in%20O365%20who%20do%20not%20have%20an%20ATP%20license%20(question)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1602826%22%20slang%3D%22en-US%22%3E%3CP%3EHey%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F765650%22%20target%3D%22_blank%22%3E%40ColtA%3C%2FA%3E%26nbsp%3B%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ETry%20this%20as%20per%20your%20screenshot%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EGet-MsolUser%20-All%20%7C%20Where-Object%20%7B%24_.licenses.AccountSkuId%20-ne%20'reseller-account%3AATP_ENTERPRISE'%7D%20%7C%20Select-Object%20userprincipalname%2Clicenses%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%3C%2FP%3E%3C%2FLINGO-BODY%3E
Occasional Visitor

Hi All,

   

   We are trying to script a way to show users in Exchange Online who do not have an ATP license attached to them. 

 

I found this script: 

 

 

 

Get-MsolUser -All | Where-Object {$_.licenses -ne 'ATP_ENTERPRISE'} | Select-Object userprincipalname,licenses

 

 

 

However, I am trying to find a script that displays only users that do not have an ATP license so that we can quickly find them.  The above script displays all users and their licenses (including those that do not have an ATP license)

 

ATPPS.PNG

 

 

Thx

1 Reply

Hey @ColtA ,

 

Try this as per your screenshot:

 

Get-MsolUser -All | Where-Object {$_.licenses.AccountSkuId -ne 'reseller-account:ATP_ENTERPRISE'} | Select-Object userprincipalname,licenses

 

Thanks