PS script to remove AD computer using local hostname

106 views Asked by At

Using MDT for re-imaging.

Scenario:

Laptop with hostname GJ76TG-27 exists in AD in an OU called 2027

Laptop needs to be re-imaged with MDT

The customsettings.ini will want to place it into a different domain OU temporarily while the TS runs. (keeping any GPO's out of the way in the temp OU)

GOAL: I want to have the TS run a PS script to find the hostname in AD, delete delete that laptop from AD, and then continue to run the TS, which will then join the laptop (using the same hostname) to the temp OU

Once image is completed, another script will move the laptop to the proper 2027 OU

How can I get PS to find the laptop using the local hostname in AD and then delete it?

Thanks so much.

I've got the TS working great except I don't want to MANUALLY delete the laptop before re-imaging it.

0

There are 0 answers