

Managing User Attributes with Windows PowerShell and VBScript

Type Dsget /? At the command prompt for further help. The results will be piped by Dsget for the user’s samid, display name and office and saved to a text document.ĭsquery user “ou=managers,dc=es-net,dc=co,dc-uk” | dsget user For example, to display the pre- Windows 2000 logon name of Geoff Prior in the Managers OU, use the following command:ĭsget user “cn=Geoff Prior,ou=Managers,dc=es-net,dc=co,dc=uk”Įxample of using Dsget to pipe the results of a Dsquery, the following command will query Active Directory for all users in the Managers OU. Instead, it reports the current value of the attribute. For example, Dsget takes the samid parameter like Dsadd does, but it does not take a value. Unlike Dsadd and Dsmod, Dsget takes only a parameter and not an associated value. You can supply the DNs of one or more user objects by specifying them on the command line, separated by spaces by entering them in the console or by piping the results of a DSQUERY USER command. The Dsget command gets and outputs selected attributes of one or more objects. hmdir “\\DC1\users\%username%\documents” -hmdrv “U:“Īs mentioned in Lesson 1, the special %username% token can be used to represent the sAMAccountName of user objects when using DS commands to configure the value of the -email, -hmdir, The following command changes the homeDirectory and homeDrive attributes of user objects in the Managers OU:ĭsquery user “ou=Managers,dc=es-net,dc=co,dc=uk” | dsmod user

Type DSMOD USER /? for usage information and a list of supported parameters.Ī more sophisticated way to send DNs to the Dsmod command is by piping the results of a Dsquery command.Īs an example, assume you want to assign all users a home folder on DC1. For example, the following command changes the Office attribute of Tony Krijnen:ĭsmod user “cn=Tony Krijnen,ou=Managers,dc=es-net,dc=co,dc=uk” The remaining parameters indicate the attribute to change and the new value. The UserDN parameter specifies the distinguished name of the user to modify.
