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
Trying to make this script work, But seems to be not working