Apr 08 2020
08:55 AM
- last edited on
Apr 01 2022
09:29 AM
by
TechCommunityAP
Apr 08 2020
08:55 AM
- last edited on
Apr 01 2022
09:29 AM
by
TechCommunityAP
Hello I am trying to get a PS script to go through a list of users and filter it out so only the F3 SKU users are listed as TRUE in the isLicensed column in the .csv output. The issue I am having is that when I run the script it is showing ALL users from the users.txt file as TRUE (meaning they should be F3) but when double checking random users they are show up as E3. The script I am using is below. I was told that using the -notmatch should work but no dice. Any ideas how I can get this to work? Many thanks!
Get-content c:\temp\users.txt | foreach {Get-MsolUser -UserPrincipalName $_ | Where-Object {($_.licenses).AccountSkuId -notmatch "SPE_E3"}} | Select-Object UserPrincipalname,islicensed | Export-csv c:\temp\Users_Without_E3.csv
Apr 09 2020 12:25 AM
Apr 09 2020 05:23 AM
Hello@Thijs Lecomte and thanks for the reply. Yes I have verified the SKU id for the a known E3 user and a known F3 user in the list to verify the correct SKU id is being used in the script.
Thanks.
Apr 13 2020 01:09 AM
Apr 14 2020 12:51 AM
Hello@charlie4872 !
I've tried the same script and other variations of my own and I got it to work correct.
Is it possible for you to share the Source file ( users.txt ) so I can see what fields you have and if something there might be wrong?
Also, maybe convert the txt to csv format and see if that works better?
Try and work with variables instead of using so many pipes as well.
I managed to do this with a few users with the following script ( I used another SKU tho )
Connect-Msolservices
$Users = Import-csv -Path "C:\Path\Users.csv
$SKU = "O365_BUSINESS_ESSENTIALS"
Foreach ($User in $Users) {
Get-Msoluser -UserPrincipalName $User.UserPrincipalName | Where-Object {($_.Licenses).accountSkuId -notcontains $SKU} | Export-csv "C:\Path\Export.csv"
Let me know how it goes
Kind Regards
Oliwer Sjöberg