Avatar of K B
K B
Flag for United States of America asked on

PowerShell: Where-Object not working as a filter

I can't seem to limit this $userLicenses (without actually explicitly setting it)

What am I missing?

 $userLicenses = $userLicense | ? {$usersku -eq 'contoso:ENTERPRISEPACK'}

Open in new window


$UserLicenses yields all the user's licence SKUs, instead of the one.
PowershellMicrosoft 365ExchangeActive Directory.NET Programming

Avatar of undefined
Last Comment
Jason Crawford

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
footech

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Jason Crawford

What is the value of the $userLicense and $usersku variables?

Here's an example if you were working with objects returned from the Get-MsolAccountSku cmdlet:

Get-MsolAccountSku | Where-Object {$_.accountskuid -eq 'contoso:ENTERPRISEPACK'}

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61