Forum Discussion
charlie4872
Mar 18, 2020Brass Contributor
Finding opposite of Where-Object -match
I have been using a power shell script to find (from a list of users in a .txt file) who are licensed for a specific SKU in Office 365. The script is..... Get-content c:\temp\users.txt | fore...
VasilMichev
Mar 18, 2020MVP
Did you try -notmatch? 🙂 Or you can prefix the entire condition with the -not operator.
charlie4872
Mar 18, 2020Brass Contributor
VasilMichev Thanks for your reply I ran the script like below
$FormatEnumerationLimit=-1
Get-content c:\temp\users.txt | foreach {Get-MsolUser -UserPrincipalName $_ | Where-Object {($_.licenses).AccountSkuId -notmatch "MCOMEETADV"}} | Select-Object UserPrincipalname,islicensed | Export-csv c:\temp\list.csvand it returned a list of users who are licensed.