Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-ADComputer Exclusions Text File

$
0
0

I am in the process of writing a script that will pull all XP machines that are still enabled on our domain.  I have a few exclusions that I know about and know that list will grow as we get closer to the end of XP.  Below is what I have for the script.

Get-ADComputer -Searchbase $SearchOU -Properties * -Filter {OperatingSystem -Like '*Windows*XP*' -and Name -NotLike Computer1 -and Name -NotLike Computer2 -and Enabled -Eq 'True'} | Select Name,OperatingSystem,LastLogonDate,CanonicalName,Enabled | Export-Csv c:\temp\CorpXpComputers.csv

What I would like to do is create a variable for $Exclusions and put all the pc names in to a text file so that I just edit that when I need to make updates.  When I try the below code I get machines that are in my exclusion text file.

$Exclusions = Get-Content "c:\temp\Exclusions.txt"
Get-ADComputer -Searchbase $SearchOU -Properties * -Filter {OperatingSystem -Like '*Windows*XP*' -and Name -NotLike $Exclusions -and Enabled -Eq 'True'} | Select Name,OperatingSystem,LastLogonDate,CanonicalName,Enabled | Export-Csv c:\temp\CorpXpComputers.csv


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>