Avatar of Anthony K O365
Anthony K O365
Flag for United States of America asked on

Powershell Command 'Where' clause issue

In running the Get-mailboxStatistics, I keep getting the following error:

Get-MailboxStatistics |Where {$_.alias -eq 'Jsmith'}

"The term 'Where' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again."

I also tried the ? alias, same error.  Any thoughts?
PowershellExchange

Avatar of undefined
Last Comment
Patrick Bogers

8/22/2022 - Mon
Patrick Bogers

Hi

Shouldnt Where be substituted by Where-Object and add the server like below?

Get-MailboxStatistics -server serverhere |Where-Object {$_.alias -eq 'Jsmith'}

Please try it, havent got PS near now.
Patrick Bogers

*
Anthony K O365

ASKER
The server switch doesn't make a difference. Getting same error.

At one time I was able to use Get-MailboxStatistics -database MB1 |Where-Object {$_.alias -eq 'Jsmith'}

Not sure what happened.
Your help has saved me hundreds of hours of internet surfing.
fblack61
ASKER CERTIFIED SOLUTION
Anthony K O365

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.
Patrick Bogers

It looks like a valid command....

Super !!!
Anthony K O365

ASKER
I've requested that this question be closed as follows:

Accepted answer: 0 points for ktookes's comment #a39766388

for the following reason:

I was able to solve this by closing and reopening the PS Session. Worked!
Patrick Bogers

Sorry for objecting but i corrected the command from the question which worked.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.