[英]Import users attributes from CSV file to Active Directory ( Updating AD )
I am trying to import some of the parameters from csv file to AD.I want to match the data by e-mail.I am using Quest ActiveRoles Management Shell. 我正在尝试将某些参数从csv文件导入AD。我想通过电子邮件匹配数据。我正在使用Quest ActiveRoles Management Shell。
Import-Csv c:\Test.csv |ForEach-Object {
Set-QADUser 'ou=User,ou=Accounts,ou=PL,dc=test,dc=com'
if(($_.E-mail Address)=mail){ $_.HR Department Code -department
$_.HR Department Code -telephoneNumber $_.Reports to L1 Formal Name -manager}
else
(Write-Host 'ERROR, User not present in AD')
}
What is wrong with this loop? 这个循环有什么问题? Is it possible to do it with this white spaces like in "HR Department Code" , I tried replacing it with variables but it does not work. 是否可以使用“人力资源部门代码”中的空白来做到这一点,我尝试用变量替换它,但是它不起作用。 I was using this idea to write this. 我用这个想法写这个。 I am using $_. 我正在使用$ _。 to match it with my column/att name from csv 使其与csv中我的列/ att名称匹配
http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/ http://dmitrysotnikov.wordpress.com/2008/10/03/update-active-directory-user-accounts-from-csv-file/
**Update **更新
Code that I am currently using: 我当前正在使用的代码:
Import-Csv 'C:\Test_Peoplesoft.csv' | foreach-object{set-qaduser -mail $_.'E-mail Address' -Department $_.'HR Department Code' -telephoneNumber $_.'HR Department Code'}
Right now nothing is happening, it just starts and never stops, looks like nothing happens. 现在什么都没有发生,它只是开始而从未停止,看起来什么都没有发生。 I have skipped manager field since there has to be a login and in my csv file is right now in this field full name of a supervisor. 我已经跳过了manager字段,因为必须进行登录,并且在我的csv文件中,此字段现在是主管的全名。
I dont think that your if statement is actually comparing your csv email and your AD email. 我不认为您的if陈述实际上是在比较您的csv电子邮件和您的AD电子邮件。 Just use the email as the identity parameter: 只需将电子邮件用作身份参数:
Import-Csv $file | foreach-object{set-qaduser $_.email -Department $_.department -Manager $_.manager -Title $_.title -ObjectAttributes @{employeeID=($_.employeeID)}}
Obviously there are some attributes I added for the example that you aren't using. 显然,我为您未使用的示例添加了一些属性。 Also replace my header names with your actual header names. 还要用您的实际标题名称替换我的标题名称。 I also try to avoid spaces in my headers in CSVs. 我还尝试避免CSV标题中的空格。 the none standard attributes like employee ID and extension attributes etc will need to be set in the -objectAttributes 无需在-objectAttributes中设置诸如雇员ID和扩展属性等标准属性
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.