Posts Tagged ‘ou’

Hi folks,

for several reasons you have to do an export of users with some attributes. To do this easily you can use CSVDE (Comma Separated Value Data Exchange) to export users from specified OUs to an CSV file:

csvde.exe -m -n -u -f c:\temp\userexport_ou01.csv -d “ou=01,dc=yourdomain,dc=com” -l “samaccountname,sn,mail,msexchhomeservername”

Thanks to Yusuf for his great export article -> Yusufs Directory Blog

Cheers,

Chris

Often you need to create some users for test purposes. Here you have a PowerShell script, which will do this procedure for you.

# Get domain and distinguished name
$Domain = (Get-ADDomain).distinguishedname

# Where to place the created users
$TargetOU = “Test”

# distinguished name for OrgUnit
$OUDN = “OU=$TargetOU,$Domain”

# How many users should be created
$NumberUsers= 50

# fill up description field with text and date
$Datetime = get-date -format G
$DField = “TEST ENVIRONMENT USER $datetime”

# OrgUnit check
$OU = Get-ADOrganizationalUnit -Filter { name -eq $TargetOU }
if($OU -eq $null)
{New-ADOrganizationalUnit -Name $TargetOU -Path $Domain}
else
{write-host “OU” $OU ” already there”}

# User creation

$u = 1
While ($u -le $usercount)
{
$UserName = “User” + $u
$UserDisplayName = “Testuser ” + $u
New-ADUser –Name $UserName –SamAccountName $UserName –DisplayName $UserDisplayName `
-Path $OUDN –Enabled $true –ChangePasswordAtLogon $true -description $DField `
-AccountPassword (ConvertTo-SecureString “YOUR_PASSWORD” -AsPlainText -force) -PassThru
$u = $u + 1
}

Cheers,

Chris