<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Is it possible to retrieve the &amp;quot;Last Used&amp;quot; property when viewing License Activity through the ArcGIS API for Python? in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657698#M11726</link>
    <description>&lt;P&gt;This is brilliant, thank you so much!&lt;/P&gt;&lt;P&gt;In case it helps others who come across this post, I'll share what I added - this prints out a formatted report and sorts by usage date, with the oldest usage dates on top.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from datetime import datetime
agol = GIS("home")

# Generate a report for applications
report = agol.admin.usage_reports.applications(time_frame = "90days")

# We are only interested in ArcGIS Pro usage
arcgispro_report = [entry for entry in report["data"] if entry["appId"] == "arcgisprodesktop"]

user_data = []

# Collect all user data with their last usage dates
for user in arcgispro_report:
    username = user["username"]
    
    last_usage = None

    # search through user data in reverse chronological order
    for epoch, usage in reversed(user["num"]):
        if int(usage) &amp;gt; 0:
            last_usage = int(epoch)
            break

    if last_usage:
        last_usage_date = datetime.utcfromtimestamp(last_usage / 1000).strftime("%m/%d/%Y")
        sort_timestamp = last_usage
        has_usage = True
    else:
        last_usage_date = "More than 90 days"
        sort_timestamp = 0
        has_usage = False
    
    user_data.append({
        'username': username,
        'last_usage_date': last_usage_date,
        'sort_timestamp': sort_timestamp,
        'has_usage': has_usage
    })

# Sort: first by has_usage (False first), then by sort_timestamp (ascending)
user_data.sort(key=lambda x: (x['has_usage'], x['sort_timestamp']))

# Print formatted table
print("\n" + "=" * 100)
print(" " * 30 + "ARCGIS PRO USAGE REPORT - LAST 90 DAYS")
print("=" * 100)
print(f"{'#':&amp;lt;3} {'Username':&amp;lt;55} {'Last Usage':&amp;lt;15} {'Days Ago':&amp;lt;10} {'Status':&amp;lt;12}")
print("-" * 100)

for i, user_info in enumerate(user_data, 1):
    username = user_info['username']
    last_usage_date = user_info['last_usage_date']
    
    if not user_info['has_usage']:
        status = "INACTIVE"
        days_ago = "90+"
    else:
        days_since = (datetime.now() - datetime.utcfromtimestamp(user_info['sort_timestamp'] / 1000)).days
        days_ago = str(days_since)
        if days_since &amp;lt;= 7:
            status = "ACTIVE"
        elif days_since &amp;lt;= 30:
            status = "RECENT"
        else:
            status = "STALE"
    
    print(f"{i:&amp;lt;3} {username:&amp;lt;55} {last_usage_date:&amp;lt;15} {days_ago:&amp;lt;10} {status:&amp;lt;12}")

print("-" * 100)
print(f"Total Users: {len(user_data)}")
print(f"Active Users (≤7 days): {len([u for u in user_data if u['has_usage'] and (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 7])}")
print(f"Recent Users (8-30 days): {len([u for u in user_data if u['has_usage'] and 8 &amp;lt;= (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 30])}")
print(f"Stale Users (31-90 days): {len([u for u in user_data if u['has_usage'] and 31 &amp;lt;= (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 90])}")
print(f"Inactive Users (&amp;gt;90 days): {len([u for u in user_data if not u['has_usage']])}")
print("=" * 100)&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 14 Oct 2025 15:03:46 GMT</pubDate>
    <dc:creator>Katie_Clark</dc:creator>
    <dc:date>2025-10-14T15:03:46Z</dc:date>
    <item>
      <title>Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1656769#M11708</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I found this related &lt;A href="https://community.esri.com/t5/arcgis-rest-apis-and-services-questions/retrieve-arcgis-pro-license-activity-through-rest/td-p/1374370" target="_blank" rel="noopener"&gt;post&lt;/A&gt; but no answer from it, wondering if there are any other insights.&lt;/P&gt;&lt;P&gt;I was hoping to be able to write a Notebook that would use the ArcGIS API for Python and query the license activity for ArcGIS Pro licenses in my organization. I am specifically interested in the "Last Used" property, which indicates when someone last opened a session within ArcGIS Pro. This information is different from their last login to ArcGIS Online.&lt;/P&gt;&lt;P&gt;I have not been able to find a way to access this info through the API - is it accessible anywhere programmatically?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Katie_Clark_0-1760032767730.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141692i0AB2ADB66560775E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Katie_Clark_0-1760032767730.png" alt="Katie_Clark_0-1760032767730.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Katie_Clark_1-1760032914605.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/141694i96971A4BC709059F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Katie_Clark_1-1760032914605.png" alt="Katie_Clark_1-1760032914605.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Oct 2025 18:10:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1656769#M11708</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2025-10-09T18:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657272#M11711</link>
      <description>&lt;P&gt;I haven't opened ArcGIS Pro today, yet when I check my last used it says today.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Oct 2025 11:58:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657272#M11711</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-10-11T11:58:30Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657437#M11715</link>
      <description>&lt;P&gt;Interesting.... do you know if there's another method of getting this information, then?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 15:40:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657437#M11715</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2025-10-13T15:40:58Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657452#M11716</link>
      <description>&lt;P&gt;I did a bit of a dive into it and came up with nothing that conclusively states the last time someone opened ArcGIS Pro. If I come across anything I'll be sure to share as I am also interested in that detail for reporting. It is interesting that in AGOL you can see the amount of time someone has spent using ArcGIS Pro so there must be a mechanism for start and end times per session that can possibly be tapped into.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Oct 2025 16:43:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657452#M11716</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-10-13T16:43:27Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657611#M11719</link>
      <description>&lt;P&gt;Here's what I found. This does it for the last 90 days. You could use a start time for the 90 days prior to that last 90 days for more info and combine.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from datetime import datetime

## access agol
agol = GIS("home")

## generate a report for applications
report = agol.admin.usage_reports.applications(time_frame = "90days")

## we are only interested in ArcGIS Pro usage
arcgispro_report = [entry for entry in report["data"] if entry["appId"] == "arcgisprodesktop"]

## for each user report
for user in arcgispro_report:
    print(user["username"])

    ## get when the last usage of ArcGIS Pro occured
    last_usage = None

    for epoch, usage in reversed(user["num"]):
        if int(usage) &amp;gt; 0:
            last_usage = int(epoch)
            break

    if last_usage:
        last_usage_date = datetime.utcfromtimestamp(last_usage / 1000).strftime("%d/%m/%Y")
    else:
        last_usage_date = "More than 90 days"

    print("\t", last_usage_date)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope that helps.&lt;/P&gt;&lt;P&gt;All the best,&lt;/P&gt;&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Tue, 14 Oct 2025 08:40:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657611#M11719</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-10-14T08:40:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657698#M11726</link>
      <description>&lt;P&gt;This is brilliant, thank you so much!&lt;/P&gt;&lt;P&gt;In case it helps others who come across this post, I'll share what I added - this prints out a formatted report and sorts by usage date, with the oldest usage dates on top.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
from datetime import datetime
agol = GIS("home")

# Generate a report for applications
report = agol.admin.usage_reports.applications(time_frame = "90days")

# We are only interested in ArcGIS Pro usage
arcgispro_report = [entry for entry in report["data"] if entry["appId"] == "arcgisprodesktop"]

user_data = []

# Collect all user data with their last usage dates
for user in arcgispro_report:
    username = user["username"]
    
    last_usage = None

    # search through user data in reverse chronological order
    for epoch, usage in reversed(user["num"]):
        if int(usage) &amp;gt; 0:
            last_usage = int(epoch)
            break

    if last_usage:
        last_usage_date = datetime.utcfromtimestamp(last_usage / 1000).strftime("%m/%d/%Y")
        sort_timestamp = last_usage
        has_usage = True
    else:
        last_usage_date = "More than 90 days"
        sort_timestamp = 0
        has_usage = False
    
    user_data.append({
        'username': username,
        'last_usage_date': last_usage_date,
        'sort_timestamp': sort_timestamp,
        'has_usage': has_usage
    })

# Sort: first by has_usage (False first), then by sort_timestamp (ascending)
user_data.sort(key=lambda x: (x['has_usage'], x['sort_timestamp']))

# Print formatted table
print("\n" + "=" * 100)
print(" " * 30 + "ARCGIS PRO USAGE REPORT - LAST 90 DAYS")
print("=" * 100)
print(f"{'#':&amp;lt;3} {'Username':&amp;lt;55} {'Last Usage':&amp;lt;15} {'Days Ago':&amp;lt;10} {'Status':&amp;lt;12}")
print("-" * 100)

for i, user_info in enumerate(user_data, 1):
    username = user_info['username']
    last_usage_date = user_info['last_usage_date']
    
    if not user_info['has_usage']:
        status = "INACTIVE"
        days_ago = "90+"
    else:
        days_since = (datetime.now() - datetime.utcfromtimestamp(user_info['sort_timestamp'] / 1000)).days
        days_ago = str(days_since)
        if days_since &amp;lt;= 7:
            status = "ACTIVE"
        elif days_since &amp;lt;= 30:
            status = "RECENT"
        else:
            status = "STALE"
    
    print(f"{i:&amp;lt;3} {username:&amp;lt;55} {last_usage_date:&amp;lt;15} {days_ago:&amp;lt;10} {status:&amp;lt;12}")

print("-" * 100)
print(f"Total Users: {len(user_data)}")
print(f"Active Users (≤7 days): {len([u for u in user_data if u['has_usage'] and (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 7])}")
print(f"Recent Users (8-30 days): {len([u for u in user_data if u['has_usage'] and 8 &amp;lt;= (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 30])}")
print(f"Stale Users (31-90 days): {len([u for u in user_data if u['has_usage'] and 31 &amp;lt;= (datetime.now() - datetime.utcfromtimestamp(u['sort_timestamp'] / 1000)).days &amp;lt;= 90])}")
print(f"Inactive Users (&amp;gt;90 days): {len([u for u in user_data if not u['has_usage']])}")
print("=" * 100)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Oct 2025 15:03:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657698#M11726</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2025-10-14T15:03:46Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657992#M11727</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/232739"&gt;@Katie_Clark&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;- this is great, thank you both for posting.&amp;nbsp; We adopted Named User model this week and as such I just began looking into usage reports and this will help greatly. I was wondering however if either of you have come across anything that can force a session close.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I began looking into the api here&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/python/latest/api-reference/arcgis.auth.html#arcgis.auth.api.EsriSession.close" target="_blank"&gt;https://developers.arcgis.com/python/latest/api-reference/arcgis.auth.html#arcgis.auth.api.EsriSession.close&lt;/A&gt;&lt;/P&gt;&lt;P&gt;but so far have not come across anything to loop through open pro sessions and close them down as way to make certain we don't have any users connected to SDE and/or network directory locations while in pro that may produce locks on file gdb layers.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not quite sure where to initiate an EsriSEssion.close(). If I come across anything I'll post a new question, and reference you guys and this post....Otherwise, if you come across anything that would be great.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 13:06:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1657992#M11727</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2025-10-15T13:06:47Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658005#M11729</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/10568"&gt;@DavidColey&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;I haven't come across anything that forces an ArcGIS Pro session close. About 8 years ago with ArcMap I had a script that would remove all locks on an SDE connection, but that's as far as I went. I will certainly keep an eye out and when I have time look more into the link you provided.&lt;/P&gt;
&lt;P&gt;All the best,&lt;/P&gt;
&lt;P&gt;Glen&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 13:42:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658005#M11729</guid>
      <dc:creator>Clubdebambos</dc:creator>
      <dc:date>2025-10-15T13:42:43Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658015#M11730</link>
      <description>&lt;P&gt;Hi Glen, thanks.&amp;nbsp; Yeah we have arcpy code to disconnect users from sde so like you we are ok there.&amp;nbsp; From what I can read in the auth package the EsriSession.close() method works off something called the EsriSession.adapters property, but I have no idea how to get to that and so I don't know what that dictionary would even list.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/417766"&gt;@Clubdebambos&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 14:15:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658015#M11730</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2025-10-15T14:15:11Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658018#M11731</link>
      <description>&lt;P&gt;From what I can tell, closing the "session" here is referring to closing the Python-side http session, so it would be useful for ending a script's authenticated connection to the GIS account.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If you are able to have remote control over someone's machine, you could maybe utilize psutil and kill the session on that machine?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 14:21:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658018#M11731</guid>
      <dc:creator>Katie_Clark</dc:creator>
      <dc:date>2025-10-15T14:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to retrieve the "Last Used" property when viewing License Activity through the ArcGIS API for Python?</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658201#M11734</link>
      <description>&lt;P&gt;Thanks for the suggestion&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/232739"&gt;@Katie_Clark&lt;/a&gt;&amp;nbsp;- that is something we've looked into before but our IT security team has ruled that out for the GIS team.&amp;nbsp; Also thanks for the insight on the 'session' property.... that sounds right.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm somewhat surprised that the usage_reports property didn't make into the PortalAdminManager, only the AGOLAdminManager.... not sure how we could get at license usage.&amp;nbsp; Maybe&amp;nbsp;&amp;nbsp;usage_reports is planned for 12.0 . . .&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Oct 2025 19:08:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/is-it-possible-to-retrieve-the-quot-last-used-quot/m-p/1658201#M11734</guid>
      <dc:creator>DavidColey</dc:creator>
      <dc:date>2025-10-15T19:08:35Z</dc:date>
    </item>
  </channel>
</rss>

