doesn't contain a method named 'op_Addition'.
尝试收集对象值并将它们添加到数组集合时,我也收到了相同的错误消息。@(
用and包裹变量时效果很好)
。
这是一篇参考文章:
PS脚本数组集合
##USER PROFILES...
$UserProfiles= @("cg2208", "cg0769", "ms8659", "sw1650", "dc8141", "bc0397", "bm7261")
$UserProfiles
$aduserlist = @()
foreach ($user in $UserProfiles {
$user
#Write-Host "Press any key to continue ..."
#$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
$aduser= Get-ADUser -Identity $user -Properties * | Select -Property SamAccountName, Name, LastLogonDate, whenCreated, msExchWhenMailboxCreated, City, State, Department, Title, mailNickname, Description
#$aduserlist += $aduser | Select Name, SamAccountName, City, State, Department, Title, whenCreated, msExchWhenMailboxCreated, mailNickname, Description
#$aduserlist += $aduser | Foreach {"$($_.SamAccountName)$($_.Name)$($_.City)$($_.State)$($_.Title)$($_.whenCreated)$($_.msExchWhenMailboxCreated)$($_.mailNickname)$($_.Description)"}
$aduserlist += @($aduser)
}
$aduserlist
$aduserlist | ft -auto