小编Rap*_*uza的帖子

某些结果的输出格式-表格线颜色

我运行下面的代码,它的工作原理:

Get-ChildItem -Path T: -Filter *.pfx | ForEach-Object { 
    Import-PfxCertificate -FilePath $_.FullName -CertStoreLocation Cert:\CurrentUser\My -Password ****** -Force -AsPlainText) -Exportable 
} |
Format-Table -Property @{Label="Computador"; Expression={$env:computername}},
    @{Label="Nome"; Expression={$_.FriendlyName}},
    @{Label="Validade"; Expression={$_.NotAfter}},
    @{Label="Impressão digital"; Expression={$_.Thumbprint}} -AutoSize
Run Code Online (Sandbox Code Playgroud)

我试图用红色的过期证书来写每一行。如果我试试这个:

Get-ChildItem -Path T: -Filter *.pfx | ForEach-Object { 
    Import-PfxCertificate -FilePath $_.FullName -CertStoreLocation Cert:\CurrentUser\My -Password ****** -Force -AsPlainText) -Exportable 
} |
Format-Table -Property @{Label="Computador"; Expression={$env:computername}},
    @{Label="Nome"; Expression={$_.FriendlyName}},
    @{Label="Validade"; Expression={$_.NotAfter}},
    @{Label="Impressão digital"; Expression={$_.Thumbprint}} -AutoSize |
Out-String | Write-Host -ForegroundColor Red
Run Code Online (Sandbox Code Playgroud)

所有线条都变成红色。如果我尝试将 $_ 值传递给 If,控制台会说这是一个 Null 值。

有什么建议?


我想做的事情的解决方案是由 …

powershell

1
推荐指数
1
解决办法
1530
查看次数

标签 统计

powershell ×1