Forum Discussion
add computers to security group automatically
- Jan 21, 2021
did you add the * after the desktop1
try this small change
$AllPC=Get-ADComputer -Filter 'SamAccountName -like "desktop*"'
Hi, do you know whcih version i need for the other commands to work is that powershell version 7?
Now tht the script works is there also a way to exclude some names with DESKTOPNR?
I would like to run this command every week so that computers which are not a member of the testgroup will be added as member but there are 10 computers with the name dekstop111, desktop112,desktop250 and so 10 total.
Is it possible to exclude these, these 10 computers must be added to another group: prodgroup.
- farismalaebJan 21, 2021Steel Contributor
Its Powershell and everything is doable, but first, you need to think about it,
Logically what is the common thing between this computer object and build the filter based on that.
I would suggest updating a computer object attrib or custom attrib then exclude these object with these attrib from the query.