0
1
For all intents and purposes, I am a novice with PS.
The command I'd like to run (it works when run manually) is:
(I realize parts are probably redundant)
Start-Process -WindowStyle hidden "$psHome\powershell.exe" -verb runas -ArgumentList "-file c:\distributedfiles\source.ps1 -ErrorAction SilentlyContinue"
I want this ^ command to execute from a Scheduled Task which needs to be created via powershell.
I've tried such things as:
schtasks.exe /create /tn backuptest /tr "c:\distributedfiles" "powershell.exe `-executionpolicy unrestricted -file c:\distributedfiles\source.ps1 -verb runas -erroraction silentlycontinue`" /d mon /sc once /st 12:33 /rl highest /f /z
To no success. I know I am wayyy off the mark with my syntax. Help would be appreciated!
edit: in this case would it be easier to just have 2 .ps1 files one with my Start-Process command, it would be invoked by scheduled task - then invoke my main source script? I sorta imagine that being easiest.
Glad this helped, but just in case --- know these details ... 'https://devblogs.microsoft.com/powershell/windows-powershell-2-0-deprecation --- https://www.stigviewer.com/stig/windows_10/2017-02-21/finding/V-70637 'Enhance PowerShell security' – https://sysmanrec.com/140-2' --- 'https://www.stigviewer.com/stig/windows_10/2017-02-21/finding/V-70637' --- 'https://sysmanrec.com/140-2'
– postanote – 2020-01-28T01:28:32.243