+4 votes
205 views
PowerShell in Windows Server 2008

in Windows Server by (551k points)
reopened | 205 views

1 Answer

+5 votes
Best answer

POWERSHELL INSTALLATION

In the Windows 2008 server it already comes as a feature of the operating system. Then we will run the "Server Manager" . Our favorite tool in a Server!

image

  • On the next screen we click on "Add Features".
  • We can see a list of available features, but we are going to activate Windows POWERSHELL.
  • When you click on the "NEXT" button, the following screen will appear informing you of what is going to be installed. If we agree with this and that is yes, click on the "INSTALL" button .
  • Now we can run WINDOWS POWERSHELL from the start menu. In the following image we can see the POWERSHELL running.

image


image


CREATE A USER FOR AD USING POWERSHELL

We will connect to the "USUARIES" OU . To do this, we will save the connection in a variable that in this case we will call: $ rquagliano.

$ rquagliano = [ADSI] "LDAP: // OU = users, DC = rqua, DC = local"

From the previous command we understand that WINDOWS POWERSHELL uses the adapter type "ACTIVE DIRECTORY SERVICES INTERFACE" to communicate with Active Directory objects. It also uses an LDAP query to connect to the Active Directory object.
Now we have a variable ($ rquagliano) that contains the connection to the OU users , that is, $ rquagliano is a reference to the object "users"

Now we will have to execute the "CREATE" command
The "CREATE" command requires two parameters passed as arguments. The class of the object and the RDN of it.
Remember that the RDN in this case would be: "CN = Ricardo Quagliano".
Of course, the class of the object we want to create is "user".

$ rqUser = $ objOU.Create ("user", "CN = Ricardo Quagliano")

In this case we are saving a variable with the name "$ rqUser".

Fill the object with the "PUT" method
We already know that there are attributes that are mandatory when creating a user object. Well, The required attribute is the "PRE-WINDOWS 2000 LOGON NAME".
The LDAP name for this attribute is: "sAMAccoutName".
Apart from this required attribute, there are many others, some of them are:

USERPRINCIPALNAME, DISPLAYNAME, GIVENNAME, SN, DESCRIPTION, COMPANY, DEPARTMENT, TITLE, MAIL .

There are many more, in this case we will complete a few properties.

$ rqUser.Put ("sAMAccountName", "qricardo")

$ rqUser.Put ("userPrincipalName", "qricardo")

$ rqUser.Put ("email", "[email protected]")


With these attributes we can start to execute commands, but if we want to know all the properties that we can use, we can do it from the properties of a user of the Active Directory.

To do this, we just have to launch the SetInfo () command of the object, like the following:

$ rqUser.SetInfo ()


With these commands we can make the creation of a user in our AD, we have to keep in mind that when throwing the different commands in our POWERSHELL , we will not be receiving any type of message, only the user will create us in our AD, where we can then go to modify the properties of it.

by (3.5m points)
edited

Related questions

+5 votes
1 answer
asked Jun 24, 2019 in Windows Server by backtothefuture (551k points) | 229 views
+3 votes
1 answer
+3 votes
1 answer
asked Jun 24, 2019 in Windows Server by backtothefuture (551k points) | 184 views
+4 votes
1 answer
+5 votes
1 answer
asked Jun 24, 2019 in Windows Server by backtothefuture (551k points) | 203 views
Sponsored articles cost $40 per post. You can contact us via Feedback
10,634 questions
10,766 answers
510 comments
3 users