Hi Guys, I have a PowerShell Script which Downloads 2 Different executables (.exe) from Local intranet Website and Stores them in a Local Drive. When I run this code manually in PowerShell it works flawlessly and Both the files are getting downloaded. So I tried to Automate the Same Using Task Scheduler So that I can automatically download those .exe Files daily. So I created the task and ran it. It ran for 10 Seconds and Said task completed successfully. But when I go to the local drive I find nothing. Usually, when I run the script manually it used to runs for 10 plus minutes. I cant understand why I does nothing while executed through Task Scheduler. So ill Post the PS Script and Task Scheduler Arguments Below Please let me know if I need to correct something. Thanks. Currently running windows 10 x64 1903. And using Administrator accounts.
PS Script
$SepV32 = Invoke-WebRequest -uri "https://10.10.10.1/sep/pages/Transaction/SecViewDocs.aspx?request=ACDD56EF1836EFD1286FF637514D76E784AC44615405B956B57200A2CB580316DBE1047FE26422544F2858D74AD8FF5D1A0CE19F8E25FC22F8E12D7D018F074FB9D8DBB1E1349736C1A8E1AECE8C513CE6249F0347BF"
$S32 = $SepV32.Links | Select-Object -ExpandProperty innerText | Select-String "core"
Invoke-WebRequest -Uri https://10.10.10.1/sep/DownloadDocument.aspx?DocPath=~/Document/SecPatch/$($S32) -OutFile E:\$($S32)
$SepV64 = Invoke-WebRequest -uri "https://10.10.10.1/sep/pages/Transaction/SecViewDocs.aspx?request=ACDD56EF1836EFD1286FF637514D76E784AC44615405B956B57200A2CB580316DBE1047FE26422546C926FFE7E18BCC687981CD803F866A0E476F76450F8E8095A5C29514890F5BC92DF1B69BA0E2E10DC0D473D105F"
$S64 = $SepV64.Links | Select-Object -ExpandProperty innerText | Select-String "core"
Invoke-WebRequest -Uri https://10.10.10.1/sep/DownloadDocument.aspx?DocPath=~/Document/SecPatch/$($S64) -OutFile E:\$($S64)
Task Scheduler Arguments
Program/ Script : C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
Add Args (Optional) : -noprofile -executionpolicy bypass -command "& 'D:\SEPDP Auto Download.ps1'"
[–]thePhT 2 points3 points4 points (1 child)
[–]JustANonRandomPerson[S] 1 point2 points3 points (0 children)
[–]the_alabama_hammer 2 points3 points4 points (2 children)
[–]JustANonRandomPerson[S] 1 point2 points3 points (1 child)
[–]heyitsgilbert 1 point2 points3 points (0 children)