i hope the title of this post isnt very confusing...
at work, all our computers have names based on the users username, and what i need to do is to update an AD group with the computernames belonging to a list of users.
so, i started out with
get-adgroupmember -identity "superusers" | select object -property SamAccountName | | foreach {$_.samaccountname}
this nets me a sweet list of all the user IDs like "ABCD" and "EFGH"
Then i though i could ask the AD for the corresponding computername, like this:
Get-ADComputer -Filter 'name -like "ABCD-*"' | Select-Object -Property name
and that works like a charm!
getting this to work together is what i need some help with though, i thought i could mash it up like this:
$superusers = Get-ADGroupMember -Identity "superusers" | Select-Object -Property SamAccountName | foreach {$_.samaccountname}
foreach ($user in $superusers)
{
Get-ADComputer -filter 'Name -like "$user"'
}
but it doenst work =/
i do get the results i want in the $superusers variable but from there on.... im stuck!
any ideas?