PowerShell OSD scripts to Add/Remove Computer from AD group and set AD Description

Here are three of the scripts in Powershell instead, AddtoADGroup, RemoveFromADGroup And SetADdescription. They can be downloaded here:

All scripts have to run in full OS and not in WinPE.

AddToADGroup

The script adds the computer it is being executed on to one or more AD Groups. “:” is the separator and if there is a space in the group name use “” as well. The account used to run the step must have permissions in AD to execute the command.
Example command line:
Powershell.exe -NoProfile -ExecutionPolicy Bypass –File AddToGroups.Ps1 “group1”:”group2”

RemoveFromADGroup

The script removes the computer it is being executed from one or more AD groups. “:” is the separator and if there is a space in the group name use “” as well. The account used to run the step must have permissions in AD to execute the command.
Example command line:
Powershell.exe -NoProfile -ExecutionPolicy Bypass –File RemoveADGroups.Ps1 “group 1”

SetADDescription

Sets a Description in AD on the computer object in AD it uses the name of the computer it is being executed on. Use “” around the description if the description contains spaces.

Example Command Line:
Powershell.exe -NoProfile -ExecutionPolicy Bypass –File SetComputerDesc.Ps1 “Test Computer”

Please follow and like us:
error

Add a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.