2012-06-25 25 views
0

我已經得到了以下工作:PowerShell中的Set-QADGroup

get-QADGroup -SearchRoot 'ex.local/' -LdapFilter '(samaccountname=test_group*)' -GroupType 'Distribution' -IncludedProperties "displayName", "mailNickname", "name", "mail" | foreach-object { 
    Set-QADGroup $_ –displayName ("new_displayname") 
} 

我不能讓下面的性質的工作:/

mail 
mailNickname 
name 
cn 
dn 

這背後的原因是因爲我們將重新命名AD中的每個對象(數千個組),並且我需要更改所有屬性。

一直在閱讀Quest,但它們只佔用displayName作爲示例,沒有什麼更進一步。

+0

同樣的問題http://stackoverflow.com/questions/11190501/set-qadgroup-setting-properties –

回答

0

您可以使用參數(例如Email和DisplayName)設置一些值。您可以使用ObjectAttributes參數設置沒有相應參數的屬性。它需要一個哈希表,其中鍵名是LDAP屬性名稱。

Get-QADGroup -SearchRoot 'ex.local/' -SamAccountName test_group* -GroupType Distribution -IncludedProperties displayName,mailNickname,name,mail | Foreach-Object { 
    Set-QADGroup $_ -DisplayName "new_displayname" -Email "newemail" -ObjectAttributes @{attrib1="new_attrib1"; attrib2="new_attrib2"} 
} 

要重命名的對象使用Rename-QADObject小命令