how can I grep a result with powershell ?

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

thanks !!!!
grep-computername-.JPG
Comment
Watch Question

Do more with

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

Open in new window

Chris DentPowerShell Developer
Top Expert 2010
Commented:
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?

Author

Commented:
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