开发者

Creating User Accounts in Active Directory using QAD Cmdlets in Powershell

I'm currently working on a powershell script that will look at a CSV file, take the information enclosed and (along with several values defined in the script) populate AD user attributes.

Originally I had this working, but all the predefined values were in the CSV file (that was converted from a开发者_Go百科n Excel spreadsheet) but the formulas would not persist line by line.

So I moved them into the script, but it just pauses as if it's waiting on more input.

Here is what the CSV file currently will contain

FirstName,LastName,Department,Title,PhoneNumber

Joe,Schmoe,Support,Someone of Something,###-###-####

and here is the import script

Import-CSV $newHire | ForEach-Object -process {new-QADUser -ParentContainer $OU -Name = $_.FirstName $_.LastName -FirstName $_.FirstName -LastName $_.LastName -DisplayName = $_.FirstName $_.LastName -SamAccountName = $_.FirstName'.'$_.LastName -UserPrincipalName = _.FirstName'.'$_.LastName'@domain.com' -Email = _.FirstName'.'$_.LastName'@emaildomain.com' -LogonScript logon.bat -Department $_.Department -Title $_.Title -PhoneNumber $_.PhoneNumber -UserPassword p@55w0rd -Company "CompanyName"}

The variables for $OU and $newHire are working correctly and contained on shared folders accessible to my user account.

Any assistance would be greatly appreciated!


Start with this:

-Name = $.FirstName $.LastName

The parser is going to choke on that, thinking $_.LastName is an argument for a positional parameter.

Try this:

-Name ($.FirstName + " " + $.LastName)

Hard to tell what else is going on there, but it looks like everywhere you've used multiple properties of the user to set a parameter need to be fixed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜