在Active Directory中更新的Active Directory用户属性中使用PowerShell [英] Updating Active Directory user properties in Active Directory using Powershell
本文介绍了在Active Directory中更新的Active Directory用户属性中使用PowerShell的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Windows Server 2003 R2环境中,使用PowerShell的2.0版,如何将一个复制的的设置 - QADUser 来更新Active Directory用户属性,就像他们的电话号码和标题?
In a Windows Server 2003 R2 environment, using Powershell v2.0, how would one duplicate the functionality of Set-QADUser to update user properties in Active Directory, like their phone number and title?
诀窍这里是我想做到这一点,而不依赖于集-QADUser,我没有使用Server 2008中的命令行开关,但该选项。
The trick here being, I would like to do this without depending on Set-QADUser and I do not have the option to use the Server 2008's commandlets, yet.
感谢。
推荐答案
从互联网附近凑合的东西放在一起,我想出了这个...
Piecing things together from around the internet, I came up with this...
function Get-ADUser( [string]$samid=$env:username){
$searcher=New-Object DirectoryServices.DirectorySearcher
$searcher.Filter="(&(objectcategory=person)(objectclass=user)(sAMAccountname=$samid))"
$user=$searcher.FindOne()
if ($user -ne $null ){
$user.getdirectoryentry()
}
}
$user = Get-ADUser 'UserName'
# Output all properties
$user.psbase.properties
# Change some properties
$user.title = 'New Title'
$user.telephoneNumber = '5555551212'
$user.SetInfo()
# Output the results
$user.title
$user.telephoneNumber
详细信息
- Using PowerShell to work with ADSI to manage an Active Directory environment
- SelfADSI : The ADSI Scripting Tutorial / The LDAP Scripting Tutorial
- IADsUser Interface
这篇关于在Active Directory中更新的Active Directory用户属性中使用PowerShell的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文