-
1. Re: Anyone using the local scheduler to run powershell scripts?
phoffmannMay 25, 2017 7:49 AM (in response to Gjstewart)
Not usually using the local scheduler for this - I usually use the schduler side for it (along with Windows Actions) ...
Bear in mind that Local Scheduler runs as LOCAL SYSTEM - so you may want to look at the machine policy in PowerShell .
-
2. Re: Anyone using the local scheduler to run powershell scripts?
Gjstewart May 25, 2017 9:38 AM (in response to phoffmann)Hey Paul - thanks
I can see powershell.exe launch with the scheduler ( i had a separate task just launching the powershell.exe with no script ) but was not sure if the local scheduler could handle calling a script after.
I am assuming it can as its definitely launched the main exe.
I am fine with system - this is checking for pending reboots and writing the data to a custom field.
So you are running a windows scheduled task?
-
3. Re: Anyone using the local scheduler to run powershell scripts?
phoffmannMay 25, 2017 9:49 AM (in response to Gjstewart)
No - I'm using a "Actions" package usually myself (as in "Software Distribution" type policy that runs every now & then) . But there's no "wrong" way ... whatever works for you & it's just a few lines of Powershell at the end of the day .
-
4. Re: Anyone using the local scheduler to run powershell scripts?
Gjstewart May 25, 2017 9:58 AM (in response to phoffmann)I see...
It is but as its reporting all different reasons for pending reboots and this could happen at any time - need it to be as real time as possible - i wanted to trigger it as a user logs on to update it everytime - actions are scheduled tasks right?
Or can you tie them into each log on? I might play with launching a bat file to launch the PS script or just the cmd /c powershell - was just curious if i was missing something -
thanks for responses!
-
5. Re: Anyone using the local scheduler to run powershell scripts?
Gjstewart Jun 20, 2017 12:37 PM (in response to Gjstewart)For anyone wanting to do it you can do it like this... create a bat file which the local scheduler calls and have this as the contents..
@ECHO OFF
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Remove-Item c:\ProgramData\LocalSched -Type Directory -recurse -Force"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "New-Item c:\ProgramData\LocalSched -Type Directory -Force"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Copy-Item '\\server\ldlogon\packages\powershell\LocalTasks\*' 'c:\ProgramData\LocalSched' -recurse -force"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Start-Sleep -sec 10"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& 'c:\ProgramData\LocalSched\Get-Reboot_Status.ps1'"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Start-Sleep -sec 10"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& 'c:\ProgramData\LocalSched\GatherUSB.ps1'"
PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "Start-Sleep -sec 10"
"%programfiles%\LANDesk\LDClient\startasuser.exe" PowerShell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -Command "& 'c:\ProgramData\LocalSched\MapDrive.ps1'"
notice startasuser for when we wanted drive info...or anything pertinent to the user.
-
6. Re: Anyone using the local scheduler to run powershell scripts?
phoffmannJun 21, 2017 5:41 AM (in response to Gjstewart)
Nice - thanks for the sharing!
As an aside (since there's always at least 3 ways of doing essentially "the same thing" in LDMS) ... we do have a "Windows Actions Package" (which is Powershell) that you could use as a repeatable task for such things as well.
Granted - that's based / run from the Core - so won't work if you've got offline laptops for instance - but it's something to be kept in mind as a more controllable policy option.