我有一个返回注册表项的脚本,但结果不会显示返回密钥的计算机。
我如何修改此代码,以便列出计算机和密钥。
$key={(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release).Release}
$computers = @(Get-Content computers.txt)
foreach ($computer in $computers){
Invoke-Command -computer $computer -scriptblock $key >> version.csv}
答案 0 :(得分:2)
下面应该做你需要的:
$key={(Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -Name Release).Release}
$computers = @(Get-Content computer.txt)
foreach ($computer in $computers){
$result = Invoke-Command -computer $computer -scriptblock $key
$FinalStr = "$($Computer) : $($result)"
$FinalStr >> version.csv
}