I need to check the following code against a txt file with computer names, so if the computer name exist in the file, it'll be copied to the shadow group.
Powershell
$OU="OU=Computers,DC=mylab,DC=local"$ShadowGroup="CN=SelectPCs,OU=Groups,DC=mylab,DC=local"Get-ADComputer–SearchBase$OU–SearchScopeOneLevel–LDAPFilter"(!memberOf=$ShadowGroup)"|ForEach-Object{Add-ADPrincipalGroupMembership–Identity$_–MemberOf$ShadowGroup}I tried a pipe and 'Where', but couldn't make it work:
Powershell
$OU="OU=Computers,DC=mylab,DC=local"$ShadowGroup="CN=SelectPCs,OU=Groups,DC=mylab,DC=local"$PCList=c:\scripts\computernames.txtGet-ADComputer–SearchBase$OU–SearchScopeOneLevel–LDAPFilter"(!memberOf=$ShadowGroup)"**|Where-Object{$_.Name–Match$PCList}**|ForEach-Object{Add-ADPrincipalGroupMembership–Identity$_–MemberOf...