Powershell导出CSV错误

Powershell导出CSV错误,powershell,active-directory,export-to-csv,Powershell,Active Directory,Export To Csv,我只是想知道你是否能帮我。我收到以下错误: Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null. At C:\PSScripts\CompassADStaff.ps1:33 char:20 + $Staff | Export-Csv <<<< CompassADStaff.csv -NoTypeInformation + CategoryInfo

我只是想知道你是否能帮我。我收到以下错误:

Export-Csv : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\PSScripts\CompassADStaff.ps1:33 char:20
+ $Staff | Export-Csv <<<<  CompassADStaff.csv -NoTypeInformation
+ CategoryInfo          : InvalidData: (:) [Export-Csv], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.ExportCsvCommand
任何帮助或指点都很好:)


谢谢

请确认,您是否可以检查$staff中是否存在以下数据:

If ($Staff) {$Staff | Export-Csv CompassADStaff.csv -NoTypeInformation }

这始终为我解决了同样的问题:

$Staff | Where {$_} | Export-Csv CompassADStaff.csv -NoTypeInformation 

当您尝试导出$Staff时,您确定其中有数据吗?完全如我所述,csv是用所需数据创建的。只是它犯了错误。谢谢你的代码对我来说很好。据我所见,导出前$Staff为空时将生成错误。正如您所说,它仍在输出数据,我不知道是什么原因导致了它。
$Staff | Where {$_} | Export-Csv CompassADStaff.csv -NoTypeInformation