how can I grep a result with powershell ?

NAMEWITHELD12 used Ask the Experts™
I want to be able to filter when I run "get-childitem env:" and get back only the COMPUTERNAME

thanks !!!!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2014
If you just want the computername, there's no reason to use Get-ChildItem.

Open in new window

Chris DentPowerShell Developer
Top Expert 2010
It's a key / value list, it's just presented like a drive. You can access elements explicitly by name:
Get-ChildItem env:\ComputerName

Open in new window

Or using wildcards:
Get-ChildItem env:\comp*

Open in new window

Why do you need to use grep on environment variables?


perfectomundo !!!!

thanks you save me a lot of time looking for this !!!!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial