I am fairly new to PowerShell and just trying to get plug some gaps with my main support role using PowerShell, so far its been great however I am currently stuck on trying to find a solution for the following.
Here is a sample of the input data:
enter image description here
Here is an example of how I would like that data to look
enter image description here
This is the code I have created so far, hopefully I am on the right track:
$csv_file = Import-Csv "C:TestOther_Managers.csv" |
Group-Object "Group Name" | Foreach-Object {
$groups = $_.Group."Group Name";
$users = $_.Group."User ID";
Write-host $groups
Write-host $users
}
foreach ($row In $groups){
Write-host $row
$output = $row | Select @{Name="Group";Expression={$groups}},
@{Name='Users';Expression={($users-join ',')}};
Write-host $row
Write-host $output
$output | Export-Csv -Path "C:TestOther_Managers_out.csv" -NoTypeInformation
}
However the output is currently:
enter image description here
JEH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.