将域组加入本地管理员组首页 系统管理脚本 脚本 本地管理员组 域组提问:如何制作一个将域组加入本地管理员组的脚本(最好用VBS) (测试环境:Windows 2000 professional 繁体版 Service Pack 4) ========================================================================== VBScript Source File -- Created with SAPIEN Technologies PrimalScript 3.1 NAME: addLogon User to local administrator.vbs.vbs AUTHOR: , gnaw0725 DATE : 2004-5-19 COMMENT: 这个脚本将域中一个指定的全局组加入到本地管理员组。 ========================================================================== Option Explicit Dim WshNetwork Dim LocalGroup Dim LocalComputer Set WshNetwork = WScript.CreateObject("WScript.Network") LocalComputer = WshNetwork.ComputerName Set LocalGroup = GetObject("WinNT://" + LocalComputer + "/Administrators,Group") If LocalGroup.IsMember("WinNT://domain_netbiosname/domain_group") Then WScript.Quit Else LocalGroup.Add "WinNT://domain_netbiosname/domain_group" End If 这个任务,也可以通过批处理来完成。而且实际运用过程中,使用net localgroup在计算机登陆到域的时候,处理速度要比vbs来得快。脚本如下: net localgroup administrators domain_group /add /domain net localgroup的语法如下: The syntax of this command is: NET LOCALGROUP [groupname [/COMMENT:"text"]] [/DOMAIN] groupname {/ADD [/COMMENT:"text"] | /DELETE} [/DOMAIN] groupname name [...] {/ADD | /DELETE} [/DOMAIN] NET LOCALGROUP modifies local groups on computers. When used without options, it displays the local groups on the computer. groupname Is the name of the local group to add, expand, or delete. Supply only a groupname to view a list of users or global groups in a local group. /COMMENT:"text" Adds a comment for a new or existing group.Enclose the text in quotation marks. /DOMAIN Performs the operation on the domain controller of the current domain. Otherwise, the operation is performed on the local workstation. name [ ...] Lists one or more usernames or groupnames to add or to remove from a local group. Separate multiple entries with a space. Names may be users or global groups, but not other local groups. If a user is from another domain, preface the username with the domain name (for example, SALESRALPHR). /ADD Adds a groupname or username to a local group. An account must be established for users or global groups added to a local group with this command. /DELETE Removes a groupname or username from a local group. NET HELP command | MORE displays Help one screen at a time. 如果变化一下,需要将当前登陆用户添加到本地管理员组,可以这样写 oLocalGroup.Add ""WinNT://domain.my/"&sLogonUserName" 如果用批处理,可以这样写 net localgroup administrators %username% /add 当在实际环境中不推荐这样做,因为这样的,所有登陆到域的账户对于域中任何受脚本影响的计算机,都会成为管理员,这样无疑是非常危险的。 喜欢这篇文章吗?那就点击 订阅吧
首页|
评论 2 |
引用 1 |
编辑 按下键盘Ctrl+D会有惊喜发生 上一篇日志:<< 关于枚举本地账户信息的脚本
|
没找到?尝试站内搜索吧!
6月最热文章
虚拟化技术 如何减小pagefile系统文件太大小 将域组加入本地管理员组文章评论:
将域组加入本地管理员组文章归档: |
本页精品文章:将域组加入本地管理员组
活动目录SEO博客公告
月流量突破 10 万,总流量突破170万,如果您对活动目录域及网络管理也有心得,并且希望以此扩大自己影响力,只需要添加本站链接,然后将文章标题和链接在线留言给活动目录博客,活动目录博客将收录您的文章,并注明您的站点及链接。