powershell - 执行操作的访问权限不足 - Powershell

标签 powershell permissions active-directory powershell-2.0

我正在编写一个简单的脚本来将 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。

最佳答案

以管理员身份运行 powershell。

关于powershell - 执行操作的访问权限不足 - Powershell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14282855/

相关文章:

powershell - 如何从 -WhatIf 处理中排除 block ?

php - 无法在服务器上保存文件

c# - 使用PrincipalContext和PrincipalSearcher从单独的服务器访问Active Directory用户

oauth-2.0 - Active Directory 是否不支持使用 PKCE 的授权代码流?

arrays - 在 PSCustomObject 数组中查询具有最大值的行

Powershell将行附加到for循环中的变量

c# - 在 c# 中重新创建 Az.Connect-AzAccount

linux - 通过智能 HTTP 推送到 Git Shared Repo 的权限不足

postgresql - 仅使用 SELECT 从 information_schema 查找 Postgresql 中表的主键

c# - 如何使用 C# 获取 Active Directory 中所有域的列表