4

我正在编写一个简单的脚本来将 AD 组成员身份从一个用户复制到另一个用户。我只使用 ActiveDirectory 模块。

该脚本看起来可以工作并且确实可以工作,直到我尝试将组广告给用户。

代码:

import-module ActiveDirectory
$templateUser = get-ADUser user1
$targetUser = getADUser user2

$groups =get-adprincipalgroupmembership $templateUser
$groups2 = get-ADPrincipalGroupMembership $targetUser

foreach($group in $groups) {
    add-adGroupMember $group $targetUser
}

错误:

Add-ADGroupMember : insufficient access rights to performt the operation
At line:9 char:18
+ FullyQualifiedErrorID : Insufficient access rights to perform the operation,Microsoft.ActiveDirectory.Management.Commands.AddADGroupMember

笔记/想法:

我以普通用户身份登录,但我以其他用户(我的管理员帐户)身份运行 powershell。我不是本地管理员,但我是域管理员。如果我启动 AD 工具并手动执行,我可以将用户添加到组(我有权添加到这些组)。

编辑:

以管理员身份运行 powershell。

4

4 回答 4

7

以管理员身份运行 powershell。

于 2013-01-15T14:11:01.517 回答
2

我今天在 Server 2012 中遇到了这个问题。我以管理员身份运行 powershell,我是域管理员,我是本地管理员,我是我能找到的各种管理员。

我通过使用 Active Directory 用户和计算机工具“修复”它,将我自己添加为我试图添加用户的 AD 组的经理,并勾选该框以允许经理更改成员资格。然后我可以愉快地运行 AD-AddGroupMember。

于 2013-05-21T03:01:14.340 回答
1

我今天遇到了这个问题,一个自动化系统正在使用 powershell 脚本来处理各种事情......原来是执行策略。我们使用 ExecutionPolicy Bypass 标志运行脚本,甚至直接在脚本之外的 powershell 中运行命令也不起作用,但是一旦我们将 executionpolicy 设置为不受限制,一切都会神奇地起作用。

对我们来说,我们甚至可以创建安全组,但不能通过 powershell 将用户添加到组中,即使我们可以在 ADUC 中进行相同的更改。

于 2019-05-16T15:33:58.940 回答
0

我也遇到了这个问题,使用 Powershell 远程连接到域控制器。

在我的情况下,Include inheritable permissions from this object's parent对于我无法更改的特定对象,它被关闭了。

于 2016-08-31T19:46:15.360 回答