All right, so we just join active directory with the with the guey, and if we take a look at our active
directory server, then you're going to see that our computer was placed in the general computers account.
Now, in a multisite location with hundreds or thousands of computers, you're just not going to want
every computer that joins the domain to be in this computer, they're looking at our domain.
You can see that I've created two sites, two organizational units, one for an L.A. location and one
for a New York location.
And furthermore, I created organizational units for Macs and PCs.
So by scripting, what I would like to do is join a Mac from each location and put them in the appropriate
of you.
So to join back to the domain, we're going to have to first remove this computer from the domain.
So let's go ahead and do that.
And now that we're removed from the domain, then this computer account should go away.
OK, now, before we join the domain, we need to make sure that our computer accounts are in order
or computer names rather are in order.
So I created a script called Get Computer Names, and it basically runs the three util commands that
I showed previously.
Now, our example, what we did before, you can see everything matches and that's great.
And since this one was new out of the box and set up by John, you can see that the hostname is not
set.
What we need to do now is change the computer name to what we want our hostname to be.
So let's go and click on John's Mac and go to manage and then rename computers and let's go ahead and
put in a name that's appropriate for that Mac.
And we'll go ahead and hit rename and so that renamed the the computer name, so if we go back to get
the computer names.
We'll see that the host name is still not set.
OK, so let's go ahead and let's run the job change name for active directory.
Now, what this does is it captures the hostname or the computer name, rather, into a variable called
hostname.
And then I just have it printing it out and then it's going to set the three computer names to that
hostname.
So when we go ahead and we run this job.
It changed the names appropriately, and if we go ahead and run, get computer names again.
Then you can see that all of our names match and now we're ready to join Active Directory.
OK, so we said that we're going to do this with scripting, so what I want to do is I want to take
the computer that's in New York and L.A. and join into the domain at the same time.
And I want them to be in the respective organizational units.
So we're going to want to run the script.
I have.
So join the domain with a script.
And now let's go ahead and take a quick look at what this does.
And so I'm defining a variable that is based off of a DNS name or a DNS search name, and we're going
to truncate that value to two digits and then we're going to join the domain with our host name as the
client ID or username and password.
And here's the path to our organization unit.
Now, you can see in our path we have the variable for location and that will be populated by New York
or L.A. and we're going to be joining the atomic net domain.
Now, finally, this past interval zero, that represents how many days the computer count will try
to get a new password from the Windows Server.
Now, this is not something that users have to worry about.
It's just a Windows account thing for active directory.
The computer negotiates with the server.
Now, I have had difficulty with this set to its default of 14.
If you have laptops that are on the road and are gone for more than 14 days at a time or in a very unique
situation using a product called Deepfreeze, you're going to want to set pass Intervale to zero.
And that means that your computer account is never going to try to negotiate with the server to keep
that password up to date.
It's kind of like joining the domain again and again every two weeks to make sure that the computer
is authenticated.
You can just change it to zero if you have any of these circumstances.
Now, if your computers are always on the domain and they're hard wired, you shouldn't have any difficulty
with the with with the default of 14.
All right, now I want to show you one thing before we run this job, and as I mentioned, that our
search domain lets us know our location.
So if I look at my search domain on my New York computer, you can see that it's searches for New York.
Got a comment on that and a comment on it.
And, of course, our L.A. machine is going to look exactly the same, except for the search domain
is going to be L.A. So that's how I'm getting this information.
So now let's go ahead and run and run the script.
And if all goes well, everything will work and we will see our computers in the correct organizational
unit instead of being in the generic computers folder.
OK, the first one worked, which is New York, so let's go to Mac and it's their.
And why are you still running, but it might be there already and it is and it just changed.
So the last thing I want to do is let's go ahead and remove both of them with a script.
So I have another job in here called Enjoying a Tomate.
I don't know.
And let's go ahead and take a look at that script.
And we're going to run ads, configured command and we're going to forcibly remove using you using the
user administrator and the password.
So let's go ahead and run this job on both machines.
And they worked, and so let's go ahead and refresh might take a little longer for the L.A. one to populate
because we're in New York, but as you saw in New York, one went and now the L.A. one is also the domain
to and out of active directory.
So that's how you work with active directory using scripting.