如何从powershell命令中获取第一个输出单词



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

Get-ChildItem -Path Cert:Certificate::LocalMachineMy | findstr -i ecimas

返回输出,例如:

ffdrggjjhj     ecims.example.com

如何仅返回字符串" ffdrggjjhj"?

您应该能够像这样拆分输出:

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

通常看起来更像是这样。由于有对象,不需要解析。

get-childitem Cert:LocalMachineTrustedPublisher | where subject -match wireless | 
  select -expand thumbprint
ABCDEFABCDEFABCDEFABCDEFABCDEFABCDEFABCD

最新更新