Hi all,
I am working on a script to help me move computer objects in AD from 1 OU to another.
I have the list of OU’s loaded into an array, but I want to add a number at the beginning of each output line with a number 1,2,3,4,etc… so that you can choose a number to pick what OU to move the computer to.
Here is what I have:
#MoveOU.ps1
$Computer = Read-Host -Prompt "What server do you want to move in AD?"
$AllOU = (Get-ADOrganizationalUnit -LDAPFilter '(name=*)' -SearchBase 'OU=123,OU=xxxxxxxxxxx,OU=456,DC=xxxxx,DC=xyz' -SearchScope Subtree)
$OUArray = @($AllOU.DistinguishedName)
@OUCount = $OUArray.count
$OU = Read-Host -Prompt "What OU do you want to move it to?"
I have 149 line items from where I need to start looking. Can someone give pointers on how I can just insert a number for each line item at the beginning , like so:
1 - OU=123,OU=xxxxxxxxxxx,OU=456,DC=xxxxx,DC=xyz
2 - OU=123,OU=xxxxxxxxxxx,OU=456,DC=xxxxx,DC=xyz
3 - OU=123,OU=xxxxxxxxxxx,OU=456,DC=xxxxx,DC=xyz
etc…
I will then use this number as input to choose what OU to move the computer to.
Thanks for help,
-Matt