POWERSHELL / ACTIVEDIRECTORY
FreeIntermediateChanges dataMedium

Add users to an AD group

Paste a list or use a CSV, choose how users should be matched, then generate one script for the group update. Preview is the default.

Generated locally in your browser · Review before running · Opselith does not connect to your tenant

What this PowerShell script does

Add several Active Directory users to one group from a pasted list or CSV. You decide whether the list contains email addresses, UPNs or account names.

Requirements

  • Group - Choose the AD group to update.
  • Users - Paste one value per line or use a CSV file.
  • Match users by - Email address, UPN or account name.
  • Action - Preview first, or explicitly choose to add the users.

Environment

  • Module: ActiveDirectory
  • Permissions: Read users/groups and modify the selected group
  • Output: Console summary · optional result CSV
  • Context: Windows PowerShell 5.1 · Active Directory RSAT
  • Risk: Medium · changes group membership only in apply mode
Preview before you change the groupPreview mode reads and resolves the users but does not add them. Switch to apply only when you are ready.
NEXT STEP

Ready to configure

Choose the group, input method and user identifier. Opselith builds the script around those choices.

More about this script

Why use this template?

Use this when you already have a list of users and want to add them to an Active Directory group without hand-editing a PowerShell script.

The template uses ActiveDirectory. Preview is read-only; apply mode changes direct group membership. The generated script runs in your own PowerShell session.

Review before running

Review the target group and user matching choice before running. Preview first. Apply mode requires an explicit confirmation in the Builder.

Generate the script

  1. Open the template in the PowerShell Builder.
  2. Enter the requested values and review the module, permissions, output and risk.
  3. Generate the script, read it carefully, and test it outside production before use.

The script is generated locally in your browser. Nothing needs to be uploaded to Opselith.

Generate this script →
Before you runModule, permissions, inputs, compatibility and script checks
OPS / SCRIPT DETAILS

Script details

Builds a bulk Active Directory group-membership script from a pasted list or CSV. Choose whether users are matched by email address, UPN or account name, preview first, then apply when ready. Review these details before generating or running the script.

active-directorygroupsmembershipusersbulkimport
Generated here. Run by you.Opselith does not connect to your tenant or run PowerShell. After generating, review the script and run it in your own PowerShell session.

What it works with

Module: ActiveDirectory

ActiveDirectory lets PowerShell work with on-premises Active Directory and is normally installed through Windows RSAT.

Context: Windows PowerShell 5.1 · Active Directory RSAT

Compatibility: Run in Windows PowerShell 5.1 on a Windows system with the ActiveDirectory module available.

Permissions and changes

Permissions: Group membership write access

Risk: Medium

Changes data: running this script can modify settings or data. Check the target and test with a controlled scope first.

Changes: Preview mode is read-only. Apply mode adds resolved users to the selected Active Directory group and skips users that are already direct members.

Inputs

  • AD group name - Enter the target group, for example Finance-Users. (Required)
  • How will you provide the users? - Paste values directly, or let the generated script read them from a CSV. (Required)
  • How should users be identified? - Choose the field that matches the values you are providing. (Required)
  • Paste users - One email address, UPN or account name per line. These values are not stored in My Toolkit. (Conditional)
  • Input CSV path - Absolute Windows path to the CSV that the generated script should read. (Conditional)
  • Which CSV column contains the users? - Example: Email, UPN or SamAccountName. (Conditional)
  • What should the script do? - Preview resolves the users and shows what would happen without changing the group. (Required)
  • Type ADD to confirm - Required only when you choose Add the users. (Conditional)
  • Save a result CSV - Optional: save each input value with its resolved user and result. (Optional)
  • Result CSV path - Choose a new absolute Windows CSV path. (Conditional)

What to expect

Output: Preview/apply summary with WOULD_ADD, ADDED, already-member and error results. · Optional CSV with each supplied value, resolved identity and result.

Expect a CSV file at the path you choose. Open it in Excel or another CSV viewer and review the rows.

Example: C:\Temp\report.csv

This template is in the Free library and is generated locally in your browser. Opselith does not run it; you review and run the script in your own PowerShell session.

Example use

Builds a bulk Active Directory group-membership script from a pasted list or CSV. Choose whether users are matched by email address, UPN or account name, preview first, then apply when ready.

Enter the required values in the Builder, review the generated script and confirm the output before running it.

Before you run: Start with Preview only. Confirm the target group and how users are identified. Review unresolved or already-member rows, then switch to Add the users only when the preview is correct.
Script checksWhat has been verifiedQA reviewed
Static checksPassed
PSScriptAnalyzerPending
Real-world run testNot yet recorded
Last checkedNot yet recorded

Real-world run results are shown only after Opselith reviews and accepts a tester report.

Tester: report a result →
TEST STATUSWhat Opselith has checked

Last reviewed: 3 Sept 2026

PSScriptAnalyzer: Awaiting a release PSScriptAnalyzer gate that includes this script. No analyzer pass is claimed yet.

Pending or Not yet recorded means there is no accepted result on file yet. A passed analyzer check does not mean the script has been run in a real tenant.