通过PowerShell的修改AD中的属性(无任务) [英] Modify attributes in AD via PowerShell (no Quest)

查看:259
本文介绍了通过PowerShell的修改AD中的属性(无任务)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有用户和他们的physicalDeliveryOfficeName属性,称为Office公元设置为纽约,和其他人说芝加哥。

Say I have users and their physicalDeliveryOfficeName attribute, called Office in AD is set to New York, and others say Chicago.

我想设置一个脚本,将通过所有的用户环路。

I want to setup a script that will loop through all users.

If physicalDeliveryOfficeName = Chicago  
Set address properties   
Street: 8888 Chicago Lane  
City: Chicago  
State: IL  
Zip: 60066  
Country: United States

else if physicalDeliveryOfficeName = New York  
Set address properties  
Street: 9999 New York Lane
City: New York
State: NY
Zip: 11111
Country: United States

我似乎无法找出哪里开始..任何指针?

I can't seem to find out where to start.. any pointers?

推荐答案

假设你已经PowerShell的2.0版,您可以使用<一个href="http://www.mikepfeiffer.net/2010/01/how-to-install-the-active-directory-module-for-windows-powershell/"相对=nofollow>内置Active Directory模块的,特别是,所述的获取-ADUser便有的命令,随后设置-ADUser便有,是这样的:

Assuming you have PowerShell v2.0, you can use the built-in Active Directory module, in particular, the Get-ADUser command followed by Set-ADUser, something like:

Get-ADUser -Filter {Office -eq "Chicago"} | Set-ADUser -StreetAddress "8888 Chicago Lane City" -City "Chicago" -State "IL" -PostalCode "60066" -Country "US"

都可以按上述或通过 Get-Help的链接可用属性的完整列表和一些例子 cmdlet的。

The full list of available attributes and some examples are available by following the links above or via the Get-Help cmdlet.

如果你不是在PowerShell的2.0版和不能升级出于某种原因,你可以使用的。NET的System.DirectoryServices 命名空间以及相关的类,在这里你应该能够合理地紧跟在MSDN的例子,的如此更新这个例子搜索。此外,#1有无数的例子,虽然<一href="http://stackoverflow.com/questions/5058261/how-to-get-update-contacts-within-active-directory">this 之一看上去就快速审查特别有前途的。

If you're not on PowerShell v2.0 and can't upgrade for some reason, you can use the .NET System.DirectoryServices namespace and associated classes, where you should be able to follow reasonably closely the MSDN examples, e.g. this for updating and this example for searching. Additionally, Stackoverflow has numerous examples, though this one looks particularly promising on a quick review.

另外,我错过了href="http://technet.microsoft.com/en-us/library/ff730967.aspx" rel="nofollow">使用PowerShell和System.DirectoryServices中搜索微软例如

Also, I missed the Microsoft example of searching using PowerShell and System.DirectoryServices.

这篇关于通过PowerShell的修改AD中的属性(无任务)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆