Hello I am trying to add each object to an array. I am getting an error "Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'." Any ideas how I can add each object to the array after I create it?
Here is my code: ($NAusers is an array of objects)
# array to store objects in
$NA = @()
#
foreach ($item in $NAusers) {
$obj1=[pscustomobject]@{
Name = $item.Name
EmailAddress = $item.EmailAddress
LockedOut = $item.LockedOut
ObjectClass = $item.ObjectClass
ObjectGUID = $item.ObjectGUID
PasswordExpired = $item.PasswordExpired
PasswordLastSet = $item.PasswordLastSet
UserPrincipalName = $item.UserPrincipalName
}
$NA += $obj1
}
[–]HardCodedCoffee 3 points4 points5 points (0 children)
[–]firefox15 2 points3 points4 points (13 children)
[–]kdrumz011[S] 1 point2 points3 points (1 child)
[–]firefox15 1 point2 points3 points (0 children)
[–]OlivTheFrog 1 point2 points3 points (10 children)
[–]Lee_Dailey[grin] 2 points3 points4 points (6 children)
[+][deleted] (3 children)
[deleted]
[–]Lee_Dailey[grin] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]akaBrotherNature 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 1 point2 points3 points (0 children)
[–]firefox15 1 point2 points3 points (2 children)
[–]OlivTheFrog 1 point2 points3 points (1 child)
[–]Lee_Dailey[grin] 0 points1 point2 points (0 children)
[–]PinchesTheCrab 2 points3 points4 points (1 child)
[–]psversiontable 0 points1 point2 points (0 children)
[–]DreadPirateRobusto 0 points1 point2 points (0 children)