简体   繁体   中英

powershell script to add computername to AD group

I know the command to add the computer to an AD group, but don't know how to create a script for it using powershell?

Here's the command:

add-ADGroupMember "BRS-Groupname" -members "BAT-100971$"

I would like to get the code and extension to name it to for adding a computer account to the AD group. It would be great to have the script ask for the computername I want to be added! Thanks in advance.

So you want user input, and than you'd like to take that input and use it within your command?

Something like this?

$myVar1 = Read-Host "I have a question?"
$myVar2 = Read-Host "I have a second question?"

add-ADGroupMember "$var1" -members "$myVar2"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM