I have a list of hosts/computers in a csv file that I use. lets say list.csv
Some of the computer names in the ‘host name’ column of the csv likely have not been logged into in a while so I want to remove all rows that contain an out of date computer record.
Using below I can get all computers in the domain that have not been logged into in 90 days -ish
I want however to take that list of computers retrieved from below and run them against list.csv, where where one of the computer names matches I want to delete the entire row(s) from list.csv.
Ive tried now for a while with other articles and import-csv etc. but cant crack it.
Thanks
$list = Import-Csv “C:\list.csv”
Below supposed to get all computers that are inactive over 90 days then display all that is in $list minus the inactive machines
Search-AdAccount -ComputersOnly -AccountInactive -TimeSpan 90 | Where{ $_.Name -notin $list.‘host name’ }