January 2015
Intermediate to advanced
230 pages
5h 4m
English
Often, Active Directory objects are moved between different OUs for reorganization purposes. The following script searches the AD for the given objects and moves them to the mentioned OU target. This script works for user, computer, and group object types:
Function Move-ObjectsToOU { [CmdletBinding()] param( [Parameter(Mandatory=$true,Position=0)] [string[]]$Name, [Parameter(Mandatory=$true,Position=1)] [ValidateSet("User","Group","Computer")] [string]$Type, [Parameter(Mandatory=$true,Position=2)] [string]$TargetOUPath ) if([ADSI]::Exists("LDAP://{0}" -f $TargetOUPath)) { Foreach($ObjectName in $Name) { try { $Object = Get-ADObject -Filter { Name -eq $ObjectName -and ObjectClass -eq $Type } -EA Stop Move-ADObject ...Read now
Unlock full access