Link to home
Start Free TrialLog in
Avatar of Anthony K O365
Anthony K O365Flag 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?
Avatar of Patrick Bogers
Patrick Bogers
Flag of Netherlands image

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.
Avatar of 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.
ASKER CERTIFIED SOLUTION
Avatar of Anthony K O365
Anthony K O365
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It looks like a valid command....

Super !!!
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!
Sorry for objecting but i corrected the command from the question which worked.