I am not a great script writer. But I love using script, as it is simple but very handy
Scenario: I got a long list of machines (all.txt) that need to be processed, and part of them have already been processed by a guy. And he send me a list (processed.txt) that he have done. By using my following PowerShell script t, I can get the machine list that need to be done.
$file1 = “processed.txt”
$file2 = “all.txt”
$file3 = “unprocessed.txt”
foreach ($a in (Get-Content $file1))
{
foreach ($b in (Get-Content $file2))
{
if ($a -eq $b)
{
(Get-Content $file2) -replace “$b”,”” | Out-File $file2
}
}
}
(Get-Content $file2) | where {$_ -ne “”} | out-file $file3