I'm using a PS script to gather all of the scheduled tasks on a number of servers. I have the server names saved in a .txt file, and am referencing that in the PS script. The problem I'm having is that no matter what order I put the server names in, the output only shows the last server name in the list (i.e. it's not outputing all the tasks on all the servers, just all the tasks on the last server listed).
Here's the PS script I'm using:
Thanks in advance for any suggestions.
Here's the PS script I'm using:
Code:
$arrServers = Get-Content -path "C:\PowerShellScripts\ScheduledTasks\ServerList.txt"
ForEach ($strServer in $arrServers){
schtasks /QUERY /S $strServer /FO CSV /V | Set-Content "C:\PowerShellScripts\ScheduledTasks\ScheduledTasks.csv"
}
Thanks in advance for any suggestions.