We help IT Professionals succeed at work.

Batch creatiion of domain local groups

Simon336697
Simon336697 asked
on
Hi guys hope you are all well and can assist.

We have a need to create more than 60 domain local groups.

The naming format of each of these groups will be:

hmv_c_<XY>

where:

hmv_c_

is to be a mandatory part of each domain local groups name, and with

<XY>

a 2 digit country code, which is to be read from a text file called countries.txt


So, Id like to automate this.

<Script> countries.txt

Here is the contents of countries.txt===========================

AE
AR
AT


etc
------------------

So, basically,

I want to create domain local groups by reading countries.txt, and for each country code, create a domain local group.

Example:

<script> countries.txt

AE
AR
AT

hmv_c_AE
hmv_c_AR
hmv_c_AT

Any help greatly appreciated.
Comment
Watch Question

FOR /F "tokens=1,2 delims=," %%i in (countries.txt) do dsadd group "CN=hmv_c_%%i,OU=Organization Unit,DC=Domain,DC=Forest" -secgrp yes -scope g -desc "%%j"

This scrit also do some more: it can add comments from file:
AE, Country1
AR, Country2

Author

Commented:
Thanks so much for this.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.