Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从PowerShell命令获取输出的第一个字_Powershell - Fatal编程技术网

如何从PowerShell命令获取输出的第一个字

如何从PowerShell命令获取输出的第一个字,powershell,Powershell,我正在尝试从powershell命令的输出中获取第一个单词 Get ChildItem-Path Cert:\Certificate::LocalMachine\My | findstr-i ecimas 返回的输出如下所示: ffdrggjjhj ecims.example.com 如何仅返回字符串“ffdrggjjhj”?您应该可以这样分割输出: (Get-ChildItem -Path Cert:\Certificate::LocalMachine\My | findstr -

我正在尝试从powershell命令的输出中获取第一个单词

Get ChildItem-Path Cert:\Certificate::LocalMachine\My | findstr-i ecimas
返回的输出如下所示:

ffdrggjjhj     ecims.example.com

如何仅返回字符串“ffdrggjjhj”?

您应该可以这样分割输出:

(Get-ChildItem -Path Cert:\Certificate::LocalMachine\My | findstr -i ecimas).split()[0]

通常powershell看起来更像这样。因为存在对象,所以不需要解析

get-childitem Cert:\LocalMachine\TrustedPublisher | where subject -match wireless | 
  select -expand thumbprint

ABCDEFABCDEFABCDEFABCDEFABCDEFABCDEFABCD

我不认为这个问题应该结束,因为它看起来像是一个常见的问题,以前没有人问过。