Skip to content

ipapaengr/ADGroupMembershipManagement

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 

Repository files navigation

PowerShell Script Description This PowerShell script is designed to add users to Active Directory groups based on the information provided in a CSV file. The CSV file should have two columns with the following headers: "AD Group" and "Samaccountname". Multiple AD groups can be separated by semicolons in the CSV file if multiple groups need to be added for the same user. Not the usual format but was needed to accomodate and applicaton request.

Here is an example CSV file format:

AD Group Samaccountname
adgroup1;adgroup2;adgroup3 Samaccount1

The script imports the CSV file using the Import-Csv cmdlet and pipes the output to a ForEach-Object loop. For each row in the CSV file, the script attempts to add the user specified in the "Samaccountname" column to the group(s) specified in the "AD Group" column using the Add-ADGroupMember cmdlet.

If the user is successfully added to the group(s), the script sets the $result variable to 'Added to group'. If an error occurs during the group membership addition, the script sets the $result variable to the error message associated with the caught exception. The Select-Object cmdlet is then used to select and format the "AD Group", "Samaccountname", and "Result" columns for output.

Finally, the output is piped to Export-Csv cmdlet which exports the results of the script as a new CSV file to the specified location on the local machine.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors