It appears to have multiple problems.
Let's start by formatting the code that you posted using the Code Sample and fixing the indentation.
Function set-TaskSchedule {
$listpc = Get-Content "C:\Users\hvinnakota\Desktop\listpc.txt"
foreach ($item in $listpc) {
Invoke-Command -ComputerName $item {
Register-ScheduledJob -Name DumpLogs -ScriptBlock {
try {
Start-Process C:\Users\hvinnakota\Desktop\listpc.txt -Trigger (New-JobTrigger -Daily -At 3.00 AM) -ErrorAction Stop
Write-Host "$item is set!"
}
catch {
Write-Host "$item failed!"
Restart-Computer -ComputerName $listpc -Force -Wait
}
}
}
}
}
set-TaskSchedule
On line 7 you are doing a start-process command. And you specify a Trigger. But there is no Trigger parameter for a start process.
Register-ScheduledJob accepts Trigger so you should move that from line 7 to line 5 (outside of the scriptblock).
The process that you are trying to start is a text file. That is not executable. It might launch notepad via association, but you really should use the name of the .exe. I would assume that you want to start notepad.exe and pass the file name as a parameter. But that code is in an Invoke-Command ScriptBlock. That is an unattended session on the remote PC. You can start notepad and it will run but no one will ever see the window. It's not associated with a user's desktop session. Does that file even exist on ALL machines?
I do not understand what you are trying to accomplish with the Start-Process command.
Also within the scriptblock you are referencing the $item and $listpc variables. You can't do that without telling Powershell that the variables were defined in the part of the script that initiated the Invoke-Command. You have to refer to them as $using:item and $using:listpc.
See example 9 in this link.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/invoke-command?view=powershell-5.1
Finally you are trying to issue a Restart-Computer command, but you are not restarting just one PC, you are using the $listpc variable which would include all PC names. So you would be running a script on ALL PC's, which would in turn try to reboot ALL of the other PC's.