I don't use the QAD tools, but my guess is that New-QadUser does not return employeeNumber as one of the attributes of the resulting object. You would need to add that.
From: Candee [mailto:[email protected]] Sent: Wednesday, April 17, 2013 8:37 AM To: NT System Admin Issues Subject: Re: PowerShell noob help Okay you guys... here it is; credit card numbers changed to protect the innocent. ;) Any advice is appreciated - I can take it. Really. When it's done it sends the logs and newusers file to me. Thanks all! ___________________________________________ #Import from HR #Create SAM, UPN #modified 4/16/2013 - CDV Import-module activedirectory add-PSSnapin quest.activeroles.admanagement $newusers = "C:\temp\scripts\newusers_ver2.csv" $date = Get-Date #Exchange database for new mailboxes $userdb = "ops" #specify path to save log file $logpath = "C:\temp\scripts\Error.logs" #parent container for all new users $OU = 'ourdomain.local/organization/internal/us/greene/newusers' #create password $pass = ConvertTo-SecureString -asplaintext R@ym0nd!! -Force #Set Domain Controller Set-ADServerSettings -PreferredServer usnygrds01.ourdomain.local #Set Domain root $DNSROOT = '@'+"ourdomain.com<http://ourdomain.com/>" Start-Transcript C:\temp\scripts\Epicor_Import.logs -append $createdusers = @() Import-Csv $newusers |foreach { $preferredfirstname = $_.preferredfirstname $lastnamepreferred = $_.lastnamepreferred $SAM = $preferredfirstname.substring(0,1)+$lastnamepreferred $UPN = $preferredfirstname +"."+$lastnamepreferred+$DNSROOT $Displayname = $lastnamepreferred +" "+$preferredfirstname $Email = $UPN $testemail = get-recipient -identity $email -ErrorAction SilentlyContinue $user = Get-QADUser -SamAccountName $SAM if($user -ne $Null) { " ********************************************************************************* $($User.name) already exists - *****THIS USER NEEDS TO BE MANUALLY CREATED***** " } Elseif ($testemail -ne $Null) { " ********************************************************************************* $($DISPLAYNAME) Email address already exists *****THIS MAILBOX NEEDS TO BE MANUALLY CREATED*****" }ELSE{ " ********************************************************************************* Creating a new user account for $($DISPLAYNAME)" $NewUser = New-qaduser -name $SAM ` -parentcontainer $OU ` -userprincipalname $UPN ` -samaccountname $SAM ` -displayname $displayname ` -mail $email ` -givenname $_.preferredfirstname` -sn $_.lastnamepreferred ` -userPassword $pass ` -company $_.Company ` -department $_.department -title $_.businesscardtitle -telephonenumber $_.telephone ` -city $_.city -postalcode $_.zip -state $_.state ` -streetaddress $_.street -manager $_.manager ` -oa @{ipphone=$_.ipphone;mobile=$_.mobile;employeeid=$_.employeeid;employeenumber=$_.employeegui} ` start-sleep -s 10 if($_.mailenabled -eq 'true') { "Creating a mailbox for $($Newuser.name)" $Newuser |foreach-object {enable-mailbox -identity $newuser.email -database $userdb } ` }Else { "User does not require Email" }#end of mailenabled }#end of create new user $createdusers += $Newuser $createdusers|select name,displayname,email|export-csv "C:\temp\scripts\Epicor_export.csv" -notype } Stop-transcript On Wed, Apr 17, 2013 at 7:30 AM, Webster <[email protected]<mailto:[email protected]>> wrote: That is why you publish your code so others can use it and help you refine it. Carl Webster Consultant and Citrix Technology Professional http://www.CarlWebster.com<http://www.carlwebster.com/> From: James Rankin [mailto:[email protected]<mailto:[email protected]>] Sent: Wednesday, April 17, 2013 4:43 AM To: NT System Admin Issues Subject: Re: PowerShell noob help Well that lil' bit of PS worked so well I did a blog post about it (naturally with appropriate credits) http://appsensebigot.blogspot.co.uk/2013/04/flagging-os-of-device-connecting-to.html This is about the time I will find out it doesn't work on anyone else's infrastructure and have to spend weeks rewriting it :-( ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected]<mailto:[email protected]> with the body: unsubscribe ntsysadmin ~ Finally, powerful endpoint security that ISN'T a resource hog! ~ ~ <http://www.sunbeltsoftware.com/Business/VIPRE-Enterprise/> ~ --- To manage subscriptions click here: http://lyris.sunbelt-software.com/read/my_forums/ or send an email to [email protected] with the body: unsubscribe ntsysadmin
