Reputation: 23
I have the following line of code:
Get-Item \\MachineNAME\c$\Windows\System32\GroupPolicy\Machine\Registry.pol |
Foreach {$_.LastWriteTime}
This returns the last modified date of a given machine successfully. Using Out-File
I can write the single result to a text file.
What I would really like to do it read in a list of machine names I have and output all the results to a text file. This would show a list of machines and the last modified date next to it.
Upvotes: 0
Views: 2675
Reputation: 26120
assuming you have one machine per line in c:\temp\computers.txt, something like this could do the trick
get-content c:\temp\computers.txt | %{
$lwt= ls \\$_\c$\Windows\System32\GroupPolicy\Machine\Registry.pol | select -expand lastWriteTime
echo "$_ : $lwt" >> c:\temp\results.txt
}
Upvotes: 2