Active Directory Commands
Active Directory Commands
Active Directory Commands
com ::
> For IT community by IT community
Exchange 2007
Active Directory Commands
Exchange 2010
How to Manage Active Directory from command line
> How to add new objects to Active Directory from command line
Lync 2010
> How to delete Active Directory objects from command line
Scripting / Command-line > How to display Active Directory objects properties from command line
> How to modify Active Directory objects properties from command line
VMware
> How to move Active Directory objects from command line
BlackBerry Server (BES) > How to search Active Directory from command line
> How to manage Group Policy from command line
Windows 7
How to add new objects to Active Directory from command line
Excel Macro / VBA
H:\>dsadd /?
Description: This tool's commands add specific types of objects to the
Manage Microsoft
Windows directory. The dsadd commands:
Streamline Windows
Administration and dsadd computer - adds a computer to the directory.
Management. Free dsadd contact - adds a contact to the directory.
30-day Trial
www.systemtools.com
dsadd group - adds a group to the directory.
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
User name can be: user name, domain\user name,
or user principal name (UPN).
-p {<Password> | *}
Password for the user <UserName>. If * is used,
then the command prompts you for the password.
-c Continuous operation mode: report errors but continue
with next object in argument list when multiple
target objects are specified.
Without this option, command exits on first error.
-q Quiet mode: suppress all output to standard output.
{-uc | -uco | -uci} -uc Specifies that input from or output to pipe is
formatted in Unicode.
-uco Specifies that output to pipe or file is
formatted in Unicode.
-uci Specifies that input from pipe or file is
formatted in Unicode.
Remarks:
If a value that you supply contains spaces, use quotation marks
around the text (for example, "CN=John Smith,CN=Users,DC=microsoft,DC=com").
If you enter multiple values, the values must be separated by spaces
(for example, a list of distinguished names).
Examples:
To remove an organizational unit (OU) called "Marketing" and all the objects
under that OU, use the following command:
H:\>dsget /?
Description: This tool's commands display the selected properties
of a specific object in the directory. The dsget commands:
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
Remarks:
The dsget commands help you to view the properties of a specific object in
the directory: the input to dsget is an object and the output is a list of
properties for that object. To find all objects that meet a given search
criterion, use the dsquery commands (dsquery /?).
The dsget commands support piping of input to allow you to pipe results from
the dsquery commands as input to the dsget commands and display detailed
information on the objects found by the dsquery commands.
H:\>dsmod /?
Description: This dsmod command modifies existing objects in the directory.
The dsmod commands include:
Remarks:
The dsmod commands support piping of input to allow you to pipe results from
the dsquery commands as input to the dsmod commands and modify the objects
found by the dsquery commands.
Examples:
To find all users in the organizational unit (OU)
"ou=Marketing,dc=microsoft,dc=com" and add them to the Marketing Staff group:
H:\>dsmove /?
Description: This command moves or renames an object within the directory.
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
[-p {<Password> | *}]
[-q]
[{-uc | -uco | -uci}]
Parameters:
Value Description
<ObjectDN> Required/stdin. Distinguished name (DN)
of object to move or rename.
If this parameter is omitted it
will be taken from standard input (stdin).
-newparent <ParentDN> DN of the new parent location to which object
should be moved.
-newname <NewName> New relative distinguished name (RDN) value
to which object should be renamed.
{-s <Server> | -d <Domain>}
-s <Server> connects to the domain controller (DC)
with name <Server>.
-d <Domain> connects to a DC in domain <Domain>.
Default: a DC in the logon domain.
-u <UserName> Connect as <UserName>. Default: the logged in user.
User name can be: user name, domain\user name,
or user principal name (UPN).
-p <Password> Password for the user <UserName>.
If * is used, then the command prompts for a
password.
-q Quiet mode: suppress all output to standard output.
{-uc | -uco | -uci} -uc Specifies that input from or output to pipe is
formatted in Unicode.
-uco Specifies that output to pipe or file is
formatted in Unicode.
-uci Specifies that input from pipe or file is
formatted in Unicode.
Remarks:
If a value that you supply contains spaces, use quotation marks
around the text (for example, "CN=John Smith,CN=Users,DC=microsoft,DC=com").
If you enter multiple values, the values must be separated by spaces
(for example, a list of distinguished names).
Examples:
The user object for the user Jane Doe can be renamed to Jane Jones
with the following command:
The same user can be moved from the Sales organization to the Marketing
organization with the following command:
The rename and move operations for the user can be combined with the
following command:
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
How to search Active Directory from command line
H:\>dsquery /?
Description: This tool's commands suite allow you to query the directory
according to specified criteria. Each of the following dsquery commands finds
objects of a specific object type, with the exception of dsquery *, which can
query for any type of object:
Remarks:
The dsquery commands help you find objects in the directory that match
a specified search criterion: the input to dsquery is a search criterion
and the output is a list of objects matching the search. To get the
properties of a specific object, use the dsget commands (dsget /?).
The results from a dsquery command can be piped as input to one of the other
directory service command-line tools, such as dsmod, dsget, dsrm or dsmove.
Examples:
To find all computers that have been inactive for the last four weeks and
remove them from the directory:
To find all users with names starting with "John" and display his office
number:
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
-attr sAMAccountName userPrincipalName department
H:\>gpupdate /?
Microsoftr Windowsr Operating System Group Policy Refresh Utility v5.1
c Microsoft Corporation. All rights reserved.
Parameters:
Value Description
/Target:{Computer | User} Specifies that only User or only Computer
policy settings are refreshed. By default,
both User and Computer policy settings are
refreshed.
http://www.infotechguyz.com/cmd/activedirectorycommandline.html
http://www.infotechguyz.com/cmd/activedirectorycommandline.html