只是想知道你是否可以帮助我。我收到以下错误:
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
我的代码似乎没问题,但我似乎无法检测到 export-csv 生成上述错误的原因:
Import-Module ActiveDirectory
#-------- Object variables ----------------------------------------------
#OU's to search
$searchbase = "ou=staff1,ou=users,dc=home,dc=local","ou=staff2,ou=users,dc=home,dc=local"
$Staff = @()
#------------------------------------------------------------------------
foreach ($ou in $searchbase) {
$Staff += get-aduser -LDAPFilter "(&(objectCategory=person)(objectClass=user)(mail=*)(!(userAccountControl:1.2.840.113556.1.4.803:=2)))" -SearchBase $ou -properties * | select-object employeeID,givenName,sn,sAMAccountName,mail
}
$Staff | Export-Csv CompassADStaff.csv -NoTypeInformation
任何帮助或指示都会很棒:)
谢谢