委派控制用户组的密码重置脚本设置

Password Reset Script Setup for Delegated Control User Group

我正在尝试委派用户组(非管理员)来处理组织单位的密码重置。由于我无法在客户端计算机上安装 Active Directory 用户和计算机,因此我编写了以下两个脚本:

测试。ps1:

Invoke-Command -ComputerName DC -FilePath \DC\SharedFolder\passwordreset.ps1

密码重置。ps1:

Function GenerateStrongPassword ([Parameter(Mandatory=$true)][int]$PasswordLength)
{
    Add-Type -AssemblyName System.Web
    $PassComplexCheck = $false
    do {
        $newPassword=[System.Web.Security.Membership]::GeneratePassword($PasswordLength,1)
        If ( ($newPassword -cmatch "[A-Z\p{Lu}\s]") `
        -and ($newPassword -cmatch "[a-z\p{Ll}\s]") `
        -and ($newPassword -match "[\d]") `
        -and ($newPassword -match "[^\w]")
        )
        {
            $PassComplexCheck=$True
        }
    } While ($PassComplexCheck -eq $false)
    return $newPassword
}

Import-Module ActiveDirectory
$newPassword = GenerateStrongPassword(13)
$securePassword = ConvertTo-SecureString -AsPlainText $newPassword -Force
Set-ADAccountPassword -Identity test -NewPassword $securePassword -Reset
$newPassword

它在管理员帐户上工作正常,但它不适用于我委托控制的用户组的任何用户。它抱怨...

PS C:\Users\User1\Downloads> powershell -executionpolicy bypass -file test.ps1
[DC] Connecting to remote server DC failed with the following error message : Access is
denied. For more information, see the about_Remote_Troubleshooting Help topic.
    + CategoryInfo          : OpenError: (DC:String) [], PSRemotingTransportException
    + FullyQualifiedErrorId : AccessDenied,PSSessionStateBroken

我已验证用户组对组织单位具有以下权限:

我还验证了用户组对共享文件夹和PowerShell脚本文件有读取和读取&执行权限。我还缺少什么其他权限才能使它对非管理员用户帐户起作用。

这里的主要线索是:

[DC] Connecting to remote server DC failed with the following error message : Access is denied.

您的用户似乎没有在 DC 上创建远程 PowerShell 会话的权限。您需要授予他们在 DC 上执行命令的权限。

如果这是域控制器,您可能需要考虑在 DC 上使用会话配置设置会话,他们可以将其导入本地会话并从那里使用 ActiveDirectory cmdlet,而不是让他们在 DC 上执行操作DC本身。或者启动一个安装了 AD 模块的 VM,他们可以在上面执行脚本。大多数安全人员都不赞成授予非必要用户访问权限以在您的域控制器上执行操作。