QUERY - Command

Hi Folks,
the following line command query will work great if I do it in my Lab under powershell
query user /server:$Client | Select-String "active"

Open in new window

will output:
JohnnyC                      console             1  Active      none   3/5/2018 10:31 AM

however when in Production(different pilot PC) it will throw an error:
user : The term 'quser' 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.
but whats even more odd, is that the  command works in DOS...
has anybody gotten the same issue? or does anybody knows how to replicate that line into powershell cmdlets

this is my Powershell version


Major  Minor  Build  Revision
-----  -----  -----  --------
5      1      16299  248

Open in new window

ivan rosaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Are you maybe running this on a 64bit system, but in a 32bit PS console? query.exe/quser.exe only exist in C:\Windows\system32, not in C:\Windows\syswow64.
So either use a 64bit PS console, or use the sysnative folder to execute the 64bit program from the 32bit PS (don't search for this folder - just use it as posted):
& 'C:\Windows\sysnative\query.exe' user /server:$Client | Select-String "active"

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ivan rosaAuthor Commented:
thanks oBdA,

I just found another way also, i made a research for that 'query' and happen to be in

Open in new window

so from there I copied: query.exe & query.mui then copy it to my script folder.
then run it as:
.\query.exe user /server:localhost | Select-String "active"

Open in new window

I prefer your method better though, much cleaner as usual! are you relative of Jeff Snover by any chance? you sure know a LOT...,
ivan rosaAuthor Commented:
Thanks a lot bud!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.