<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[gOxiA=苏繁=SuFan Blog]]></title> 
<link>https://maytide.net/index.php</link> 
<description><![CDATA[gOxiA,苏繁,sufan,Microsoft MVP]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[gOxiA=苏繁=SuFan Blog]]></copyright>
<item>
<link>https://maytide.net/read.php/861.htm</link>
<title><![CDATA[将 1,000 个用户添加到安全组]]></title> 
<author>gOxiA &lt;sufan_cn@msn.com&gt;</author>
<category><![CDATA[PowerShell 和脚本]]></category>
<pubDate>Sat, 09 Jul 2005 01:25:12 +0000</pubDate> 
<guid>https://maytide.net/read.php/861.htm</guid> 
<description>
<![CDATA[ 
	<span><div><p><strong>描述<br /></strong><br />演示脚本创建一个名为 Group1 的安全组，并且将一千个用户（UserNo1 到 UserNo10000）添加到该组。此脚本不可用于生产环境。</p></div><div><p>有关使用 ADSI 创建对象的更多信息，请单击 <a href="http://msdn.microsoft.com/library/en-us/netdir/adsi/creating_and_deleting_objects.asp">此处</a>。<br /></p></div><div><p><strong><br />支持平台</strong></p></div><table border="0" cellspacing="0" cellpadding="0" class="dataTable" id="EFAA"><thead></thead><tbody><tr class="record" valign="top"><td><p class="lastInCell"><strong>Windows Server 2003</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="evenRecord" valign="top"><td><p class="lastInCell"><strong>Windows XP</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="record" valign="top"><td><p class="lastInCell"><strong>Windows 2000</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是</strong></p></td></tr><tr class="evenRecord" valign="top"><td><p class="lastInCell"><strong>Windows NT 4.0</strong></p></td><td style="border-right: #cccccc 1px solid"><p class="lastInCell"><strong>是，需要安装 Active Directory Client Extensions</strong></p></td></tr></tbody></table><div><p></p><p><br /><strong>脚本代码<br /></strong>Const ADS_PROPERTY_APPEND = 3<br />Set objRootDSE = GetObject(&quot;LDAP://rootDSE&quot;)<br />Set objContainer = GetObject(&quot;LDAP://cn=Users,&quot; &amp; _<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; objRootDSE.Get(&quot;defaultNamingContext&quot;))<br />Set objGroup = objContainer.Create(&quot;Group&quot;, &quot;cn=Group1&quot;)<br />objGroup.Put &quot;sAMAccountName&quot;,&quot;Group1&quot;<br />objGroup.SetInfo<br />For i = 1 To 1000<br />strDN = &quot;,cn=Users,&quot; &amp; objRootDSE.defaultNamingContext<br />&nbsp;objGroup.PutEx ADS_PROPERTY_APPEND, &quot;member&quot;, _<br />&nbsp; &nbsp;Array(&quot;cn=UserNo&quot; &amp; i &amp; strDN)<br />&nbsp;objGroup.SetInfo<br />Next<br />WScript.Echo &quot;Group1 created and 1000 Users added to the group.&quot;</p></div></span>
]]>
</description>
</item>
</channel>
</rss>