I want to exclude specific computer objects. I have tried something like below. but no luck.
Here is my script :
$ADComputers = @()
$ADGroups = @()
$ComputersNotInAD = @()
$GroupsNotInAD = @()
# Create a single query filter str
$OU = 'OU=Tier1,DC=contoso,DC=local','OU=Servers,DC=contoso,DC=local'
$ADComputersRaw = $OU | ForEach-Object {Get-ADComputer -Filter {Enabled -eq $True Name -notlike 'server11*' -and Name -notlike 'tstsrv11*'} -SearchBase $PSItem -Properties * | Select-Object name}
# Rebuild the lists to make them text instead of objects
ForEach($ComputerRaw in $ADComputersRaw)
{
$ADComputers += $ComputerRaw.Name
}