Can I run AD commands from a standard PowerShell script?
Posted
by Ben
on Server Fault
See other posts from Server Fault
or by Ben
Published on 2010-05-28T21:53:04Z
Indexed on
2010/05/28
22:02 UTC
Read the original article
Hit count: 313
active-directory
|powershell
I am putting together a script to run post-sysprep.
It should check if the machine is on the network, and if it is then it should query AD to see if a computer account exists with it's service tag (we're using these as the hostnames of the machines.)
If it does exist, it should delete the account and rejoin the machine to the domain.
I have got the majority of the script running, but need to run the following:
Remove-ADComputer -Identity $distinguishedName
How can I run this from the "standard" powershell environment? I don't want to use the AD module.
(By the way - I'm on a mixed mode 2000/03 domain as we are in the process of upgrading to 2008)
I'm new to PowerShell so be gentle if I'm completely missing the point!
Thanks,
Ben
© Server Fault or respective owner