Proloe 0 Newbie Poster


So I'm attempting to do a bulk creation of users into Active Directory (Server 2008) using Powershell. I have a script but every time it runs it throws a exception error. I have tried to go through and find what is wrong, but I am having little luck. Any help would be greatly appreciated!


$list = Import-Csv "userImport.csv"
foreach ($dataRecord in $list) 
$cn=$dataRecord.FirstName + ” ” + $dataRecord.LastName
$sAMAccountName=$dataRecord.FirstName + “.” + $dataRecord.LastName
$displayName=$surName + “, ” + $givenName
$userPrincipalName=$sAMAccountName + “”


At line:10 char:10
+ $objUser= <<<< $objOU.Create("user","CN="+$cn)
+ CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException
+ FullyQualifiedErrorId : CatchFromBaseGetMember
You cannot call a method on a null-valued expression.
At line:11 char:13
+ $objUser.Put <<<< ("sAMAccountName",$sAMAccountName)
+ CategoryInfo : InvalidOperation: (Put:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
(Does this for many many lines (maybe all?))

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.