如何重写此 powershell cmdlet 以产生特定的输出?
How to rewrite this powershell cmdlet to produce specific output?
我不擅长 PS 但我需要帮助..
Get-WmiObject -class DCIM_BIOSEnumeration -Namespace root\dcim\sysman | Where-Object {$_.AttributeName -Match "Trusted Platform Module Activation"} | Select CurrentValue
运行时,它将 return 1 或 2 作为当前值。
如果结果为 2,我需要脚本输出 "Detected",如果结果为 1,则不输出任何内容(空)。
有人能帮忙吗?谢谢!!
用一个if
语句来判断是否输出"Detected":
$CurrentValue = Get-WmiObject -class DCIM_BIOSEnumeration -Namespace root\dcim\sysman | Where-Object {
$_.AttributeName -Match "Trusted Platform Module Activation"
} | Select-Object -ExpandProperty CurrentValue
if($CurrentValue -eq 2) {
"Detected"
}
我不擅长 PS 但我需要帮助..
Get-WmiObject -class DCIM_BIOSEnumeration -Namespace root\dcim\sysman | Where-Object {$_.AttributeName -Match "Trusted Platform Module Activation"} | Select CurrentValue
运行时,它将 return 1 或 2 作为当前值。
如果结果为 2,我需要脚本输出 "Detected",如果结果为 1,则不输出任何内容(空)。
有人能帮忙吗?谢谢!!
用一个if
语句来判断是否输出"Detected":
$CurrentValue = Get-WmiObject -class DCIM_BIOSEnumeration -Namespace root\dcim\sysman | Where-Object {
$_.AttributeName -Match "Trusted Platform Module Activation"
} | Select-Object -ExpandProperty CurrentValue
if($CurrentValue -eq 2) {
"Detected"
}