如何将输出附加到CSV文件

问题描述 投票:-3回答:1
foreach ( $newfile in $file ) 
{ 
   $b =  Get-CMDeploymentStatus -PackageId $newfile -StatusType Any | select PackageID
 Write-Output $b | Export-Csv -Path "C:\Users\PSM-6A1A000000000000\Documents\list.csv"
}

我正在使用输入文件对此进行输入,其中列出了包名称的数量,然后我要以某种方式处理它,使得输出现在一个接一个地出现,我得到一个错误,为]]

Export-Csv:无法将参数绑定到参数'InputObject',因为它为null。在第16行:char:20 +写输出$ b | Export-Csv -Path“ C:\ Users \ PSM-6A1A000000000000 \ Documents \ lis ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo:InvalidData:(:) [:Export-Csv],ParameterBindingValidationException + FullyQualifiedErrorId :ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand

foreach($ file中的$ newfile){$ b = Get-CMDeploymentStatus -PackageId $ newfile -StatusType任何|选择PackageID写输出$ b | Export-Csv -Path“ C:\ Users \ PSM-6A1A000000000000 \ Documents \ ...

powershell sccm
1个回答
0
投票

您的代码假设您将得到从$b返回的结果,如果不是,则会出现错误,因为您正在将$b(为空)传送到Export-CSV

© www.soinside.com 2019 - 2024. All rights reserved.