My script basically runs on specific times during a day. Accesses the server and downloads data.
So far I have tried playing around with start-sleep command and timespan command but I am new to this.
start-sleep ((get-date "03:04 pm") - (get-date)).TotalSeconds; $filename = (get-date -format "hh_mm_dd_MM_yyyy") +"AU"+".csv"$xacontroller = "abc.contoso.com"$xasessions = Get-BrokerSession -AdminAddress $xacontroller - MaxRecordCount 100000 | Export-Csv -Path "C:\Temp\Data\$filename"start-sleep ((get-date "03:06 pm") - (get-date)).TotalSeconds;$filename = (get-date -format "hh_mm_dd_MM_yyyy") +"SG"+".csv"$xacontroller = "def.contoso.com"$xasessions = Get-BrokerSession -AdminAddress $xacontroller - MaxRecordCount 100000 | Export-Csv -Path "C:\Temp\Data\$filename"
Logic : sleep till 3:04 PM and run the first block. sleep till 3:06 PM and run the second block.
What I am trying to achieve : Sleep after 3:06 PM till next day 3:04 PM
Expectation : This script needs to run everyday automatically without using task scheduler. I am using powershell 3.
Any ideas are appreciated. Thank you.