简体   繁体   English

使用Powershell中的QAD Cmdlet在Active Directory中创建用户帐户

[英]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. 我目前正在研究一个Powershell脚本,该脚本将查看CSV文件,获取包含的信息,并(以及脚本中定义的多个值)填充AD用户属性。

Originally I had this working, but all the predefined values were in the CSV file (that was converted from an Excel spreadsheet) but the formulas would not persist line by line. 最初我可以进行此操作,但是所有预定义的值都在CSV文件中(从Excel电子表格转换而来),但是公式不会逐行保留。

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 这是CSV文件当前包含的内容

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. $ OU和$ newHire的变量可以正常工作,并且包含在我的用户帐户可以访问的共享文件夹中。

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. 解析器将对此感到窒息,认为$ _。LastName是位置参数的参数。

Try this: 尝试这个:

-Name ($ .FirstName + " " + $ .LastName) -名称($ .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. 很难说出那里发生了什么,但是看起来到处都是使用用户的多个属性来设置参数的地方,需要修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM