简体   繁体   中英

Powershell: How to select a specific value from an output?

Is there a way to only pullout the specific vualue from an output of a command below?

applicationName applicationId attributes
--------------- ------------- ----------
Keno_Test_App          115345 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}
Keno_Test_App2         118991 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}

I try doing something like this but its still captures both output:

PS C:\WINDOWS\system32> $getapp.applicationName
Keno_Test_App
Keno_Test_App2

Is there away to get an output like this:

PS C:\WINDOWS\system32> $getapp.applicationName
Keno_Test_App

or:

applicationName applicationId attributes
--------------- ------------- ----------
Keno_Test_App          115345 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}

If $getapp.applicationName outputs this:

Keno_Test_App
Keno_Test_App2

then ($getapp.applicationName)[0] will output:

Keno_Test_App

If $getapp outputs this:

applicationName applicationId attributes
--------------- ------------- ----------
Keno_Test_App          115345 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}
Keno_Test_App2         118991 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}

then $getapp[0] will output:

applicationName applicationId attributes
--------------- ------------- ----------
Keno_Test_App          115345 {@{name=Regions; id=2722; value=(Not Set)}, @{name=Project type; id=5162; value=(Not Set)}, @{name=Interface type; id=5163; value=(Not Set)}, @{name=Data classification; id=5164; value=(Not Set)}...}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM