Forum Discussion
Surfer10
Jan 21, 2021Copper Contributor
add computers to security group automatically
I would like to add computers in AD with names that start with desktop to a security group: testgroup. We would like to run this powershell command thru scheduled tasks to run every week so that if ...
- Jan 21, 2021
did you add the * after the desktop1
try this small change
$AllPC=Get-ADComputer -Filter 'SamAccountName -like "desktop*"'
Giancarlo135
Oct 20, 2022Copper Contributor
ADD-ADGroupMember -identity “NAME OF YOUR GROUP” –members “$env:computername$”
Comments:
The "" can be taken literally
“$env:computername$” = this is a variable that will add the Computer that the script is running on to your specified Group
Comments:
The "" can be taken literally
“$env:computername$” = this is a variable that will add the Computer that the script is running on to your specified Group