Hi all,

I was wondering if I could get some help on this script that I have been working on.

It's a small script and it works perfectly fine but the only issue I am having is getting the script to run by itself at a certain time.

The server that this will be running on will be a Windows Server 2012 R2. I have tried to add this script to the task scheduler and nothing has worked.

This happens even though I have told the Task Scheduler to run as an administrator.

The script I created is just a small script so HR can know who's really working from home and who's not, its basically an attendance sheet if you think of it.

Start-Process powershell -ArgumentList '-nonprofile -file C:\Users\lesliej\Desktop\VPN\working script.ps1' -verb RunAs
$startDate = Get-Date -Date "04/06/2020"
$endDate = Get-Date -Date "12/06/2020"
$Day = Get-Date -format "08:00:00"
$endDate = Get-Date -format "17:30:00"
$Path = "C:\Users\lesliej\Desktop\VPN\filelist.csv"
Get-RemoteAccessConnectionStatistics -StartDateTime $Day|Export-Csv "\\KL-FS01\Data\Home\LeslieJ\VPN List of users\June\VPN User List - $((Get-Date).ToString('dd-MM-yyyy - HH-mm-ss')).csv" -NoTypeInformation

Any help would be appreciated as this is getting really annoying having to do this manually.