下面是一个在 get-childitem
上使用 Expand 属性的脚本
获取子项证书:\LocalMachine\my |选择 dnsnamelist
给我如下的输出
DnsNameList
-----------
{localhost}
所以我使用扩展属性来扩展它
Get-ChildItem Cert:\LocalMachine\my | select -ExpandProperty dnsnamelist -Property notafter
这给了我如下的输出
NotAfter Punycode Unicode
-------- -------- -------
5/24/2023 5:30:00 AM localhost localhost
所以我只需要一个属性,unicode 或 punycode,所以下面是我所做的
Get-ChildItem Cert:\LocalMachine\my |
select -ExpandProperty dnsnamelist -Property notafter |
Select-Object -ExcludeProperty punycode
但这仍然给了我 unicode 和 puny 代码,如何只获取一个..
我的最后一个管道要求排除 punycode 属性,为什么这不起作用?
请您参考如下方法:
写完问题后,我找到了答案,你必须在最终管道中使用“select *
”,如下所示
Get-ChildItem Cert:\LocalMachine\my |
select -ExpandProperty dnsnamelist -Property notafter | Select * -ExcludeProperty unicode
您还可以使用如下表达式
Get-ChildItem Cert:\LocalMachine\my |
select -ExpandProperty dnsnamelist -Property notafter | select notafter,@{Name='SystemName';Expression ={$_.unicode} }