简体   繁体   English

将用户属性从CSV文件导入到Active Directory(更新AD)

[英]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.

相关问题 如何使用PowerShell将用户从CSV文件添加到Active Directory(AD)和Exchange中? - How do you add users from a CSV file to Active Directory (AD) and Exchange using PowerShell? 将批量用户(csv文件)导入2003 Active Directory服务器 - import bulk users (csv file) into a 2003 active directory server 从 csv 导入数据并创建 Active Directory 用户列表 - import data from csv and create list of Active Directory users 从活动目录创建已删除用户的CSV文件 - Create CSV file of deleted users from active directory Azure AD从CSV更新批量用户 - Azure AD Updating Bulk users from CSV 创建脚本以将用户从CSV导入AD - Creating a Script to import users from a CSV to AD 通过PowerShell脚本查询Active Directory以在csv文件中获取用户的属性 - Query Active Directory via PowerShell script to get attributes for users in a csv file 从 Csv 更新 Active Directory 字段 - Updating Active Directory Field from Csv 运行Powershell脚本以使用Import-Csv和New-QADUser将用户从csv导入到Active Directory时出错 - Error when running powershell script to import users from csv using Import-Csv and New-QADUser into Active Directory 需要从 CSV 文件更新 AD 目标用户的属性,例如 ObjectSid、msExchMasterAccountSid - Need to update attributes for AD target users such as ObjectSid, msExchMasterAccountSid from a CSV file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM