windows – 使用Powershell在Active Directory中更新Active Dire
发布时间:2021-02-22 12:10:13 所属栏目:系统 来源:网络整理
导读:在 Windows Server 2003 R2环境中,使用Powershell v2.0,如何复制 Set-QADUser的功能以更新Active Directory中的用户属性,如电话号码和标题? 这里的诀窍是,我想这样做而不依赖于Set-QADUser,但我没有选择使用Server 2008的命令行开关. 谢谢. 解决方法 从互联
|
在 Windows Server 2003 R2环境中,使用Powershell v2.0,如何复制 Set-QADUser的功能以更新Active Directory中的用户属性,如电话号码和标题? 这里的诀窍是,我想这样做而不依赖于Set-QADUser,但我没有选择使用Server 2008的命令行开关. 谢谢. 解决方法从互联网上拼凑起来,我想出了这个……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 (编辑:邯郸站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |

