每当我尝试将结果输出到 csv 文件时,我都会不断收到以下错误消息 - “不允许使用空管道元素”。知道为什么会发生这种情况吗?
$apps = Import-CSV apps.csv
$computers = Import-CSV compobj.csv
foreach($computer in $computers) {
$computerLob = $computer.lob
$lobApps = $apps | ? {$_.lob -eq $computerLob}
foreach($app in $lobApps){
$appLocation = $app.location
$installed=Test-Path "\\$computerHostname\$appLocation"
$computerHostname = $computer.hostname
$results = new-object psobject -property @{Computer=$computer.hostname;App=$app.appname;Installed=$installed} | select Computer,App,Installed
$results
}
} | Export-csv "results.csv" -NoTypeInformation
我试过这样做:
$results | Export-csv "results.csv" -NoTypeInformation
在 foreach 循环中,但它只返回最后一条记录。