I am wanting to export to a CSV, with users listed as well as the AD Group. We have users in email signatures groups to assign the correct signature. I am trying to export the users with what E-mail Sign(Security Group) they are in.<\/p>\n
Advertisement
So it would look like this:<\/p>\n
Advertisement
User Group<\/p>\n
User1 E-mail Sign<\/p>\n
User2 E-mail Sign w Pic<\/p>","upvoteCount":5,"answerCount":9,"datePublished":"2019-04-26T18:24:11.000Z","author":{"@type":"Person","name":"spiceuser-mfmvr","url":"https://community.spiceworks.com/u/spiceuser-mfmvr"},"acceptedAnswer":{"@type":"Answer","text":"
This in total was the final answer<\/p>\n
$groupNames = \"E-mail Sign - Ext - Cell - Pic\", \"E-mail Sign - Cell\", \"E-mail Sign - Direct Phone - Pic - Direct Fax\", \"E-mail Sign - Direct Phone\", \"E-mail Sign - Multi-Unit Sales\", \"E-mail Sign - Direct Phone - Cell - Pic - Direct Fax\", \"E-mail Sign - Direct Phone - Cell - Direct Fax\", \"E-mail Sign - Direct Phone - Cell - Pic\", \"E-mail Sign - Direct Phone - Pic\", \"E-mail Sign - Direct Phone - Cell\", \"E-mail Sign - Warehouse\", \"E-mail Sign - Direct Phone - Ext - Direct Fax\", \"E-mail Sign Full - Cell\", \"E-mail Sign Full - Direct Phone - Cell\", \"E-mail Sign Full - Direct Phone - Cell - Pic\", \"E-mail Sign Full - Direct Phone - Ext - Direct Fax\", \"E-mail Sign Full - Direct Phone - Pic\", \"E-mail Sign Full - Ext - Cell - Pic\", \"E-mail Sign Full - Ext - Multi-Unit Sales\", \"E-mail Sign Full - Warehouse\", \"E-mail Sign Full - Direct phone - Cell - Direct Fax\", \"E-mail Sign Full - Direct Phone\", \"E-mail Sign Full - Ext - Pic\", \"E-mail Sign - Ext - Pic\", \"E-mail Sign Full - Direct Phone - Pic - Direct Fax\", \"E-mail Sign Full - Direct Phone - Cell - Pic - Direct Fax\", \"E-mail Sign Full - Direct Phone - Direct Fax\", \"E-mail Sign - Direct Phone - Direct Fax\", \"E-mail Sign - Test\", \"E-mail Sign - Test with Pic\", \"E-mail Sign - Survey - Cell\"\n\n$usersWithGroups = [System.Collections.ArrayList]::new()\n\nforeach ($groupName in $groupNames) {\n $groupMembers = Get-ADGroupMember -Identity $groupName\n foreach ($member in $groupMembers) {\n $userWithGroup = [PSCustomObject]@{\n User = $member.SamAccountName;\n Group = $groupName \n }\n $usersWithGroups.Add($userWithGroup)\n }\n}\n\n$usersWithGroups |Export-Csv \"Users with signature group.csv\" -NoTypeInformation\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2019-04-29T14:15:18.000Z","url":"https://community.spiceworks.com/t/powershell-export-users-in-an-ad-group-like-something/709353/9","author":{"@type":"Person","name":"spiceuser-mfmvr","url":"https://community.spiceworks.com/u/spiceuser-mfmvr"}},"suggestedAnswer":[{"@type":"Answer","text":"
I am wanting to export to a CSV, with users listed as well as the AD Group. We have users in email signatures groups to assign the correct signature. I am trying to export the users with what E-mail Sign(Security Group) they are in.<\/p>\n
So it would look like this:<\/p>\n
User Group<\/p>\n
User1 E-mail Sign<\/p>\n
User2 E-mail Sign w Pic<\/p>","upvoteCount":5,"datePublished":"2019-04-26T18:24:11.000Z","url":"https://community.spiceworks.com/t/powershell-export-users-in-an-ad-group-like-something/709353/1","author":{"@type":"Person","name":"spiceuser-mfmvr","url":"https://community.spiceworks.com/u/spiceuser-mfmvr"}},{"@type":"Answer","text":"
Welcome.<\/p>\n
What have you tried? Where are you stuck?<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n