Powershell-将计算机添加到Active Directory中的安全组
如何将文本文件中的多个计算机帐户添加到Active Directory的安全组中?我将这段代码放在一起,但它只适用于用户帐户Powershell-将计算机添加到Active Directory中的安全组,powershell,active-directory,Powershell,Active Directory,如何将文本文件中的多个计算机帐户添加到Active Directory的安全组中?我将这段代码放在一起,但它只适用于用户帐户 Import-Module ActiveDirectory Get-Content C:\Servers.txt | Foreach-Object {Add-ADGroupMember "WSUS Auto Download and Notify for Install" $_} 您要查找的命令是addadprincipalgroupmembership Get-Co
Import-Module ActiveDirectory
Get-Content C:\Servers.txt | Foreach-Object {Add-ADGroupMember "WSUS Auto Download and Notify for Install" $_}
您要查找的命令是addadprincipalgroupmembership
Get-Content c:\servers.txt | Add-ADPrincipalGroupMember -memberof 'WSUS Auto Download and Notify for Install'
如果需要在计算机名称末尾添加“$”,则命令可以使用scriptblock参数(一个可以修改管道输入的异常函数)
您要查找的命令是addadprincipalgroupmembership
Get-Content c:\servers.txt | Add-ADPrincipalGroupMember -memberof 'WSUS Auto Download and Notify for Install'
如果需要在计算机名称末尾添加“$”,则命令可以使用scriptblock参数(一个可以修改管道输入的异常函数)
我使用-Identity$\ objectGUID $\u$对我不起作用
编辑:啊,对不起,那是因为我使用Get-ADComputer来传输它,而不是一个文本文件。我使用-Identity$\u0.objectGUID $\u$对我不起作用 编辑:啊,对不起,那是因为我使用Get-ADComputer来传输它,而不是文本文件。我发现类似的任务对我有用 以管理员身份在powershell中运行它
Import-Module ActiveDirectory
$List=Get-Content c:\computers.txt
$List | foreach {Add-ADGroupMember -id ADGroupName -MEMBERS (Get-ADComputer $_)
我发现类似的任务对我有效
以管理员身份在powershell中运行它
Import-Module ActiveDirectory
$List=Get-Content c:\computers.txt
$List | foreach {Add-ADGroupMember -id ADGroupName -MEMBERS (Get-ADComputer $_)
计算机的帐户名末尾加了一个$。是你干的吗?(名为“server1”的服务器的帐户名为“server1$”)计算机的帐户名末尾加了一个$。是你干的吗?(名为“server1”的服务器的帐户名为“server1$”