I am trying to initialize arrays for each unique department in a CSV file. So far I have this and it doesn't seem to be working as intended.
$Org = Import-Csv Org.csv
$Dept_Unique = $Org.Department | Select-Object -Unique
This gives me the correct output and will list all the unique values of all departments in the CSV.
Accounting Team
Human Resources
Information Technology
Then I try to initialize an array for each of the departments with just some random values.
$Dept_Unique | ForEach-Object {
$_ = @('User1','User2','User3')
}
My expected output would be...
${Human Resources}[1]
User2
However, I'm getting Cannot index into a null array.. Which tells me that array is not initializing how I want it to. Any help would be greatly appreciated, thanks!
Add-Membercmdlet to do this. What's your real goal though.$Org |Group-Object