要将当前账号添加到管理员组中,可以使用以下PowerShell脚本:

$groupName = "Administrators"
$currentUser = [System.Security.Principal.WindowsIdentity]::GetCurrent().Name

$group = [ADSI]"WinNT://./$groupName,group"
$user = [ADSI]"WinNT://./$currentUser,user"

$group.Add($user.Path)

将脚本保存为.ps1文件,并使用管理员权限运行该脚本。脚本将获取当前用户的用户名,然后将其添加到本地计算机的管理员组中。

当前账号加到管理员组中脚本

原文地址: https://www.cveoy.top/t/topic/jd54 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录