I am not very familiar with Python but am trying to write a script in ArcGIS Pro that will update the offline areas that I have created for a web map that is hosted on our organisation's Enterprise Portal. I have gotten the script to execute perfectly fine when I manually run it in Pro but I want to schedule it to run using Windows Task Scheduler so that these updates can occur outside of work hours.
I set up a schedule however when I checked back later the updates hadn't occurred. There was nothing in the 'History' pane of ArcGIS Pro that suggested the task had even attempted to run (it still said 'Scheduled'). I first thought that this was an issue with Pro being closed and the Portal not being able to be authenticated and so I scheduled the task to run again and left Pro open but the same result happened. Now I am thinking that perhaps it is not an authentication issue but something else altogether.
This is a cut-down version of the script I am trying to run;
from arcgis.gis import GIS
from arcgis.mapping import WebMap
import arcpy
gis = GIS('Pro')
GIS_admin = 'aa7f0378d0bd4c31a1bd18b2dbac1b11'
map_item = gis.content.get('686be07874f946df91d7d72b2f87e347')
map_item.unshare(groups=[GIS_admin])
WebMap(map_item).offline_areas.update()
map_item.share(groups=GIS_admin, allow_members_to_edit=True)
I have tried playing around with the settings in Windows Task Scheduler itself to 'Run whether user is logged in or not' without success. If someone has any light that they can shed that would be greatly appreciated.