Notification

Icon
Error

Creating a schduled task on remote computer

Posted: Sunday, February 21, 2021 10:57:02 AM(UTC)
Amos

Amos

Member Original PosterPosts: 1
0
Like
Hi,
Deploying a script that creates a scheduled task, creates the task but it cannot be run manually.
I am deploying as system because many remote computers may be running without a logged on user.
The same task runs OK when I run the already deployed (copied) script manually.
I have also tried to use Psexec (not from Lansweeper) and the results were good.
I have tried executing the below from LS deployment -
{PackageShare}\psexec -u [user] -p {Pass} -h cscript "C:\Windows\temp\5-WU_Weekly_schedule-DEV.vbs".
This too works when running locally but doesn't work when running by LS deployment.
What makes the difference between Psexec and Lansweeper?
Any suggestions?

Amos
steveb
#1steveb Member Posts: 35  
posted: 2/26/2021 7:44:48 PM(UTC)
Have you considered using a GPO instead?
TassieTrooper
#2TassieTrooper Member Posts: 3  
posted: 4/12/2022 8:49:36 AM(UTC)
Originally Posted by: Amos Go to Quoted Post
Hi,
Deploying a script that creates a scheduled task, creates the task but it cannot be run manually.
I am deploying as system because many remote computers may be running without a logged on user.
The same task runs OK when I run the already deployed (copied) script manually.
I have also tried to use Psexec (not from Lansweeper) and the results were good.
I have tried executing the below from LS deployment -
{PackageShare}\psexec -u [user] -p {Pass} -h cscript "C:\Windows\temp\5-WU_Weekly_schedule-DEV.vbs".
This too works when running locally but doesn't work when running by LS deployment.
What makes the difference between Psexec and Lansweeper?
Any suggestions?

Amos


Deploy a LS package 'createFooBarSystemSchedTask.PS1' script and deploy with 'Run mode - System account and it will (should) make the task...PS Script example:

#createFooBarSystemSchedTask.PS1
$action = New-ScheduledTaskAction -Execute 'foobar.exe' -Argument '"C:\Temp\foobar.txt"'

$trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Friday -At 4pm

$settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -RestartCount 3 -RestartInterval (New-TimeSpan -Minutes 30) -ExecutionTimeLimit (New-TimeSpan -Hours 1) -Priority 5

$principal = New-ScheduledTaskPrincipal -UserID "NT AUTHORITY\SYSTEM" -LogonType ServiceAccount -RunLevel Highest

Register-ScheduledTask -Action $action -Principal $principal -Trigger $trigger -Settings $settings -TaskName "my system context scheduled task" -Description "OK I hope this works."

Active Discussions

Lansweeper Adding an "Employee ID" column to an asset report
by  ABaker   Go to last post Go to first unread
Last post: Yesterday at 3:06:54 PM(UTC)
Lansweeper Firefox 102 & ESR 91.11
by  Esben.D  
Go to last post Go to first unread
Last post: Yesterday at 8:12:07 AM(UTC)
Lansweeper Performance report not shows result
by  NoraD   Go to last post Go to first unread
Last post: 6/28/2022 7:52:27 AM(UTC)
Lansweeper Duplicate AD Users
by  Randy Costa  
Go to last post Go to first unread
Last post: 6/27/2022 5:25:04 PM(UTC)
Lansweeper mail reports
by  swede   Go to last post Go to first unread
Last post: 6/27/2022 7:47:09 AM(UTC)
Lansweeper Multiple Devices Owned by Users (asset relations)
by  Adrian Scott  
Go to last post Go to first unread
Last post: 6/22/2022 5:34:51 PM(UTC)