Anyone good with hash tables ale to help out on this one. I have multiple global groups where I am gather each member of the groups. I am trying to add them to a hash table, each line contains all the information about the user account being returned where the $group is the key.
When I use $vdiArr.add I get the error Cannot find an overload for "add" and the argument count: "9". When I remove the hashed out command it works fine but the data in the array seems to be all over the place. I am trying to achieve each user's information on one line within the array. e.g vdiArr[0]={theirGroup,Name, GivenName, LastName and so on....
clear-host
$count = $null
$date = Get-Date -format "MM-dd-yyyy_hh-mm-ss"
$vdiGrps = Get-Content "D:\SourceFiles$\Scripts\Active Directory\ADGroups.txt"
$vdiArr=[System.Collections.ArrayList]@{}
$vdiArr=@{}
foreach($group in $vdiGrps)
{
$ADgroup=(get-adgroup $group -properties members).members | get-adobject | where {$_.objectclass -eq "User"}| get-aduser -properties * | select name, GivenName, Surname, UserPrincipalName, SamAccountName, Enabled, DistinguishedName
$ADgroup
$vdiArr.add($group,$ADgroup.name,$ADgroup.GivenName,$ADgroup.Surname,$ADgroup.UserPrincipalName,$ADgroup.SamAccountName,$ADgroup.SamAccountName,$ADgroup.Enabled,$ADgroup.DistinguishedName)
#$vdiArr.group = $group
#$vdiArr.Name = $ADgroup.name
#$vdiArr.GivenName = $ADgroup.GivenName
#$vdiArr.Surname = $ADgroup.Surname
#$vdiArr.UserPrincipalName = $ADgroup.UserPrincipalName
#$vdiArr.SamAccountName = $ADgroup.SamAccountName
#$vdiArr.Enabled = $ADgroup.Enabled
#$vdiArr.DistinguishedName = $ADgroup.DistinguishedName
}
$arrOutput += New-Object -TypeName psobject -Property $vdiArr
Out-File -InputObject $arrOutput -FilePath "$home\Desktop\test.csv"