windows – 使用Powershell在Active Directory中更新Active Dire
发布时间:2021-02-20 19:45 所属栏目:52 来源:网络整理
导读:在 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 (编辑:ASP站长网) |
相关内容
网友评论
推荐文章
热点阅读