Link to home
Start Free TrialLog in
Avatar of namerg
namergFlag for United States of America

asked on

How to import disable accounts from a csv into an XYZ ou in AD ?

Hello,
I have the following CSV with the following headers:
sAMAccountName	Surname	givenName	department	title	telephoneNumber	employeeNumber

Open in new window

And would to limport those users into a xyz OU in AD.

Thanks,
Avatar of Prashant Girennavar
Prashant Girennavar
Flag of India image

Try below command line,

you need to copy the samaccountname in text file

$Users = Get-content C:\adusers.txt
import-module activedirectory
foreache($user in $Users)
{
Get-ADUser $user | Move-ADObject -TargetPath 'OU=xyz,DC=Contoso,Dc=com'
}

Open in new window



Hope this helps

Thanks,

-Prashant Girennavar.
ASKER CERTIFIED SOLUTION
Avatar of coraxal
coraxal
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of namerg

ASKER

@coraxal
How do i split yuor code so i can debug it ? Like assgning the following into a variable. Import-Csv "C:\adusers.csv"