<?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: AGS admin scripting help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510972#M40149</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3147"&gt;Kevin Hibma&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;I'm making (slow) progress using the sample &lt;A href="https://community.esri.com/migrated-users/7306"&gt;James Crandall&lt;/A&gt; provided above (Many thanks for that James!) &lt;/P&gt;&lt;P&gt;Quick (?) question(s)...&lt;/P&gt;&lt;P&gt;I was looking at the samples for &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004s000000" title="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004s000000"&gt;ListingMapServices ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt;&amp;nbsp; but only seems to pass the "unsecure" services, even if I pass the token.&amp;nbsp; Your "Stop, Start, Delete services" will list them all, but is not filtered for those that are STARTED.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;How can I get a script to return all of the services (secured or not), but filtered for only those that are STARTED?&amp;nbsp; Kind of a combo of the above....but also almost opposite of both.&lt;/LI&gt;&lt;LI&gt;I might have better luck once I have it as a tool, but I'm still testing as snippets in the python window&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, long term goal (simplified)...stop only those services that are accessing the FGDB that I need to update..replace the FGDB...then start just those back up.&amp;nbsp; All while keeping credentials secure.&amp;nbsp; Simple...right.&amp;nbsp; lol.&amp;nbsp;&amp;nbsp;&amp;nbsp; I may need to look at the link James had at the beginning of the thread to see if I can do the opposite of what it is supposed to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On that same "secure" thought....is there anyway to block things being written to the results table....or to programatically remove entries from the script?&amp;nbsp;&amp;nbsp; did decide that rather than using the "agsurl " as shown in James' script, if I use the local server name and port 6080, that should prevent access from outside the network (and thinking maybe a local server account??). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Aug 2016 02:10:00 GMT</pubDate>
    <dc:creator>RebeccaStrauch__GISP</dc:creator>
    <dc:date>2016-08-10T02:10:00Z</dc:date>
    <item>
      <title>AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510957#M40134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;BR /&gt;I'm trying to build some simple service checks (map, feature and gp services) that are published on our ArcGIS Server site(s). &lt;A href="http://server.arcgis.com/en/server/10.3/administer/windows/example-check-a-folder-for-stopped-services.htm" title="http://server.arcgis.com/en/server/10.3/administer/windows/example-check-a-folder-for-stopped-services.htm"&gt;Example: Check a folder for stopped services—Documentation (10.3 and 10.3.1) | ArcGIS for Server&lt;/A&gt; is what I'm attempting to implement but having difficulty with the request at fetching the token.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I've been provided with the serverName and serverPort parameters (lines 22 and 23 of the sample code) by our AGS admin but I keep tripping the error at line 137.&amp;nbsp; If I print the response.status it shows a response of 302 and response.reason is "Found".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any input or success implementing this script?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 13:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510957#M40134</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-07-28T13:15:21Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510958#M40135</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I ditched using the REST API calls (it's infuriating to navigate and determine all of the correct required server parameters).&amp;nbsp; Simply opted for simplicity and accomplished this with urllib.open and properly setting up each individual url, taking care in constructing each one correctly.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The REST API is overly complicated for my needs.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 14:53:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510958#M40135</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-07-28T14:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510959#M40136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I may revisit the REST API as there are some other complications to overcome with the approach I took.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue with the REST API example is that it doesn't implement the requests library and instead uses urllib.&amp;nbsp; Normally not an issue, however when dealing with https and TLS &amp;amp; SSL things start to just not work as originally written!&amp;nbsp; This sends you down an entirely different path --- I may just try to re-write the sample using requests instead.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 16:31:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510959#M40136</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-07-28T16:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510960#M40137</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just to make sure you aren't reinventing the wheel, have you checked out&lt;/P&gt;&lt;P&gt;&lt;A href="https://blogs.esri.com/esri/arcgis/2012/07/05/downloadable-tools-for-arcgis-server-administration/" title="https://blogs.esri.com/esri/arcgis/2012/07/05/downloadable-tools-for-arcgis-server-administration/"&gt;Downloadable tools for ArcGIS Server administration | ArcGIS Blog&lt;/A&gt; &lt;/P&gt;&lt;P&gt;&lt;A href="http://www.arcgis.com/home/item.html?id=12dde73e0e784e47818162b4d41ee340" title="http://www.arcgis.com/home/item.html?id=12dde73e0e784e47818162b4d41ee340"&gt;http://www.arcgis.com/home/item.html?id=12dde73e0e784e47818162b4d41ee340&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 16:50:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510960#M40137</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-07-28T16:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510961#M40138</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you had a chance to setup the toolkit against HTTPS?&amp;nbsp; I'd think we'd run into the same issues I'm hitting with the example REST API script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 18:03:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510961#M40138</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-07-28T18:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510962#M40139</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This looks like a really comprehensive tool set!&amp;nbsp; But it's a bit much for what we need I think.&amp;nbsp; To go from just running a simple script to check what services are stopped/running to this is pretty extreme.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm not sure why the example script doesn't play nice with https.&amp;nbsp; Seems like something do-able to overcome.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jul 2016 18:39:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510962#M40139</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-07-28T18:39:41Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510963#M40140</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;mine runs using the machine name as input and runs again sucure and non-secure services.&amp;nbsp; I run the tool in the toolbox, then copy the snippet for input into my own script....the only thing I don't like just using this as default is the admin password is part of the snippet (in the results tab too), so be aware of that.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;sample of the script...with fake folder names for demonstration....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;arcpy.StopStartService(Server_Name="&amp;lt;machinename&amp;gt;",Port="6080",
&amp;nbsp; Admin_User="&amp;lt;adminUser&amp;gt;",Admin_Password="&amp;lt;adminPsw&amp;gt;",
&amp;nbsp; Stop__Start__Delete="Stop",
&amp;nbsp; Service_List="some_gp//ExtractData.GPServer;print//dwcGeoPDF.GPServer;our_public//GMUSubunits.MapServer;our_secure//uculines.MapServer")&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you run it once "manually" with Stop, then you can copy and change to Start to you don't always start up the services you don't want started.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:21:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510963#M40140</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T22:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510964#M40141</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I just came across this post and realize you might have a path forward.&lt;/P&gt;&lt;P&gt;Just a note though - I've been trying to make time to refresh the toolkit. That includes introducing proper HTTP&lt;STRONG&gt;S&lt;/STRONG&gt; support. If you're interested in it before its "done", its in a branch here: &lt;A href="https://github.com/khibma/ArcGISAdministrationToolkit/tree/devupdates" title="https://github.com/khibma/ArcGISAdministrationToolkit/tree/devupdates"&gt;GitHub - khibma/ArcGISAdministrationToolkit at devupdates&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm close to being done. I just need to do some more testing. After that I'll update the arcgis.com sample with the newest and greatest. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 13:42:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510964#M40141</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2016-08-04T13:42:05Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510965#M40142</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That's great, Kevin!&amp;nbsp; Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 13:50:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510965#M40142</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2016-08-04T13:50:23Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510966#M40143</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kevin,&lt;/P&gt;&lt;P&gt;This may not be the place to ask this, but since you mentioned you are working on it., is there a way that the commands can use an .ags administrator (or publisher) connection file, rather than be prompted and/or hardcoding the credentials?&amp;nbsp; It bothers me that the info ends up in the results.&amp;nbsp; Maybe that is what you are attempting (or attempting to hide) in the SSL updates??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I haven't done much directly with the ArcGIS Server REST API myself.&amp;nbsp; Just started looking at it, and the admin tools (the current release, not the gishub version, which I will try out now).&amp;nbsp; I'm trying to work on the workflow for when I need to update the source FGDB being used....i.e&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;check for any services that access the FGDB&lt;/LI&gt;&lt;LI&gt;check for those that are currently STARTED&lt;/LI&gt;&lt;LI&gt;shut those down&lt;/LI&gt;&lt;LI&gt;rename/replace FGDB&lt;/LI&gt;&lt;LI&gt;start ONLY those stopped in step 2&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Problems with the current tool is:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;it lists ALL the services, whether started or stopped already, so if I stop all the ones I need, and duplicate the list, it may start some that I had stopped on purposes already&lt;/LI&gt;&lt;LI&gt;no easy way at this time to tell those I need to shut down (i.e. filter for "services using source"&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Let me know if you need me to put this info in GitHub as a comment.&amp;nbsp; I haven't posted much to github (more of a downloader still)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 15:39:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510966#M40143</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-08-04T15:39:42Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510967#M40144</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hey Becky - The ability to use the .AGS file would be an excellent enhancement. I actually really like that idea as it hides the password from being inside your scripts. The only problem: from a pure Python code perspective, I have no way to get at the contents of the AGS file, nor is there any arcpy method that could consume the file to give me what I need. Basically we'd have to do something in the core software to assist in using the connection file to help the tools get what they need. I'll have a conversation about that with some team members.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I understand the not knowing if something is stopped or started from the tool UI. Would it simply be enough to show in the UI something like "MyService [STOPPED]"&amp;nbsp; or&amp;nbsp; "Service2 [STARTED]" ?&amp;nbsp; Or are you after an actual filter to only show certain services? I havent wrote any logic to filter, but if I dont consider it now, I probably wont look at making these tools "better" for another 4 years after this go. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 04 Aug 2016 16:30:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510967#M40144</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2016-08-04T16:30:29Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510968#M40145</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Kevin,&lt;/P&gt;&lt;P&gt;re: the .AGS file.&amp;nbsp; I thought there were other "tools" that could use this as input already. Not necessarily pure Python code, by maybe arcpy code??&amp;nbsp; I'll have to look to see if I can find any samples, or things that maybe I have used. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3147" target="_blank"&gt;Kevin Hibma&lt;/A&gt;&amp;nbsp; re: the filter.&amp;nbsp; When you startup ArcGIS Server, it does remember what was started when you shut AGS, so &lt;EM&gt;that&lt;/EM&gt; information is stored somewhere.&amp;nbsp; But obviously I'm not necessarily wanting to shut the AGS site down just to replace the source for these dozen or so services.&amp;nbsp; BTW - because my process recreates a FGDB and derived datasets each time (from a master SDE database), I can't use replicate and need to replace it each time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'll have to work on the filter part myself I think....&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;maybe use a inventory of all data sources withing all the .mxds being used by the services, search for the \\machinename\fgdbpath and/or d:\fgdbpath in that inventory.&amp;nbsp; Write a list of all these folders\services&lt;/LI&gt;&lt;LI&gt;then use something like the sample on &lt;A href="https://server.arcgis.com/en/server/latest/administer/windows/manage-service-utility.htm" title="https://server.arcgis.com/en/server/latest/administer/windows/manage-service-utility.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Manage Service utility—Documentation (10.4) | ArcGIS for Server&lt;/A&gt;&amp;nbsp; page to find all the the STARTED services&lt;/LI&gt;&lt;/UL&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;The following example lists all the services in the site.
&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&amp;lt;Python installation location&amp;gt;\python.exe "C:\Program Files\ArcGIS\Server\tools\admin\manageservice.py" -u admin -p admin -s http://gisserver.domain.com:6080 -l 

&lt;/CODE&gt;&lt;/PRE&gt;&lt;/PRE&gt;&lt;P&gt;and it looks like the the key here is the &lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;P&gt;-l Lists the services on the GIS server and displays whether they are stopped or started.&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;or use &lt;A href="https://server.arcgis.com/en/server/latest/administer/windows/example-check-a-folder-for-stopped-services.htm" title="https://server.arcgis.com/en/server/latest/administer/windows/example-check-a-folder-for-stopped-services.htm" rel="nofollow noopener noreferrer" target="_blank"&gt;Example: Check a folder for stopped services—Documentation (10.4) | ArcGIS for Server&lt;/A&gt;&amp;nbsp;&amp;nbsp; but change it to STARTED instead of STOPPED (??).&amp;nbsp; anyway, if I can just check those in the list I created, and updating the list for those that are currently STARTED&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;run the stop against my filtered list&lt;/LI&gt;&lt;LI&gt;rename/replace....&lt;/LI&gt;&lt;LI&gt;run the start on same filtered list&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm still looking around to see if anyone has already put a workflow like this together, but I think I'm going to have to write it myself.&amp;nbsp; But again, the real snag here are the admin credentials.&amp;nbsp; This is all part of a python addin toolbar, and not something I want to hardcode into my addin.&amp;nbsp; This addin &lt;EM&gt;does&lt;/EM&gt; take advantage of an .SDE connection file already, so being able to do the same with the .AGS connection file would be ideal.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I'm open to any suggestions re: getting the credentials input without exposing the info in the script, addin, or results tab (or anything that can grab the clear-text info).&amp;nbsp; Thanks much for the tools so far....I have used them often (just a pain to have to manually figure out my filtering..and of course the user/pass issue.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;btw - my sincere apologies &lt;A href="https://community.esri.com/migrated-users/7306" target="_blank"&gt;James Crandall&lt;/A&gt; for hijacking the thread, but hopefully this is something you are interested in too.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:22:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510968#M40145</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2021-12-11T22:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510969#M40146</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No problem, hijack away! &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here's an idea to keeping credentials out of things.&amp;nbsp; Well, sort of. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You could just setup a simple .ini file to hold any credentials and then use base64 library in the python scritping.&amp;nbsp; It's not a 100% secure approach, but it'd keep any hardcoded credentials out of the codebase and some low-level secuity using base64 to encode/decode that will essentially hide any variable values from view that might be set.&amp;nbsp; Like so:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*** create a "settings.ini" file and save it in the same directory as the .py script&lt;BR /&gt;[AGS]&lt;BR /&gt;USER = someusername&lt;BR /&gt;PASS = somepassword&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The implement base64 and ConfigPaser in your .py scripting:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import ConfigParser
import base64
# Find and gather settings from the settings.ini file
localPath = sys.path[0]
settingsFile = os.path.join(localPath, "settings.ini")
config = ConfigParser.ConfigParser()
config.read(settingsFile)

# Get encoded credentials
uname_encoded = base64.b64encode(config.get( 'AGS', 'USER'))
pwd_encoded = base64.b64encode(config.get('AGS', 'PASS'))

# use the encoded credentials for any login parameters
# for example, build the URL with credentials for the REST API
&lt;SPAN&gt;agsurl = '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2FyourAGSaddress" target="_blank"&gt;https://yourAGSaddress&lt;/A&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;
site = '/arcgis'
URL = agsurl + site + "/rest/services"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
# obtain a token&amp;nbsp; 
referer = agsurl
query_dict = { 'username': base64.b64decode(uname_encoded), 'password': base64.b64decode(pwd_encoded), 'referer': referer }&amp;nbsp; 
query_string = urllib.urlencode(query_dict)
url = agsurl + site + "/tokens/generateToken"
token = json.loads(urllib.urlopen(url + "?f=json", query_string).read()) 

#...blah blah blah you get the idea&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:22:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510969#M40146</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T22:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510970#M40147</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is a great suggestion. Having user/password saved in plain text is just bad form. And sadly, I've encouraged that in places (&lt;A href="https://github.com/arcpy/update-hosted-feature-service" title="https://github.com/arcpy/update-hosted-feature-service"&gt;GitHub - arcpy/update-hosted-feature-service: Update and overwrite a hosted feature service on ArcGIS.com&lt;/A&gt; ) Maybe I'll try to update that sample with your approach. And, yes, its still very possible for someone to find out the credentials. However, any sort of security is better than no security. Thanks, James.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 13:07:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510970#M40147</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2016-08-05T13:07:04Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510971#M40148</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are some tools/functions that make use of .AGS files. There is a big difference between "those tools" and the tools in the Administration toolkit. The built-in, system tools have access to all the internal workings of ArcGIS. The tools I've written in Python dont have the same level of 'arcgis' access. Simply put, the tools I wrote dont rely on ArcGIS/arcpy, and even if they did, they couldn't make use of a .AGS file to accomplish the end goal of 'administrative tasks' on the server. Those 'hooks' are not exposed in the software to 'python developers'.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You're right about the stopped|started information being held somewhere. However the interaction with the tools and the server itself is very short lived. The tools only are aware and talk to the server during their execution. As such, any tool or script needs to get all the information from the server and perform the action during that session. So the tools I wrote would need to query the server, get that information, and then perform an appropriate action. The LIST script you reference is essentially the same code I have in the STOP | START | DELETE tool. This action of getting the services and their state needs to happen each time the tool is run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The idea James offers below is a great method of hiding credentials from plain view. It isn't 100% secure (really any solution that requires you to save credentials on the client machine isn't secure). But its better plain text!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Aug 2016 13:33:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510971#M40148</guid>
      <dc:creator>KevinHibma</dc:creator>
      <dc:date>2016-08-05T13:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510972#M40149</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/3147"&gt;Kevin Hibma&lt;/A&gt; ,&lt;/P&gt;&lt;P&gt;I'm making (slow) progress using the sample &lt;A href="https://community.esri.com/migrated-users/7306"&gt;James Crandall&lt;/A&gt; provided above (Many thanks for that James!) &lt;/P&gt;&lt;P&gt;Quick (?) question(s)...&lt;/P&gt;&lt;P&gt;I was looking at the samples for &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004s000000" title="http://resources.arcgis.com/en/help/main/10.2/index.html#//00s30000004s000000"&gt;ListingMapServices ArcGIS Help (10.2, 10.2.1, and 10.2.2)&lt;/A&gt;&amp;nbsp; but only seems to pass the "unsecure" services, even if I pass the token.&amp;nbsp; Your "Stop, Start, Delete services" will list them all, but is not filtered for those that are STARTED.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;How can I get a script to return all of the services (secured or not), but filtered for only those that are STARTED?&amp;nbsp; Kind of a combo of the above....but also almost opposite of both.&lt;/LI&gt;&lt;LI&gt;I might have better luck once I have it as a tool, but I'm still testing as snippets in the python window&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Again, long term goal (simplified)...stop only those services that are accessing the FGDB that I need to update..replace the FGDB...then start just those back up.&amp;nbsp; All while keeping credentials secure.&amp;nbsp; Simple...right.&amp;nbsp; lol.&amp;nbsp;&amp;nbsp;&amp;nbsp; I may need to look at the link James had at the beginning of the thread to see if I can do the opposite of what it is supposed to do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;On that same "secure" thought....is there anyway to block things being written to the results table....or to programatically remove entries from the script?&amp;nbsp;&amp;nbsp; did decide that rather than using the "agsurl " as shown in James' script, if I use the local server name and port 6080, that should prevent access from outside the network (and thinking maybe a local server account??). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Aug 2016 02:10:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510972#M40149</guid>
      <dc:creator>RebeccaStrauch__GISP</dc:creator>
      <dc:date>2016-08-10T02:10:00Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510973#M40150</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;/P&gt;&lt;P&gt;i am using current version of AGS admin tool with the help of this tool I am to list down all stop services without error.&lt;/P&gt;&lt;P&gt;and also create one Python script to generate reports of all map services.&lt;BR /&gt;if you require then i will share with you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;thanks.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 09:24:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510973#M40150</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2016-08-12T09:24:52Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510974#M40151</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;We just have a simple need to check services to see STOPPED/STARTED status --- that's really it.&amp;nbsp; Couple of reasons why:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; To build a dashboard that can be displayed on a monitor hanging on the wall.&amp;nbsp; Pretty simple .aspx page or something like that showing Red &amp;amp; Green for stopped/started services.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; We have applications developed with the JavaScript API that other departments within the organization build and these utilize our ArcGIS Server services (map, feature &amp;amp; GP services).&amp;nbsp; With the simple code below we published as a GP service that those applications can check against to see status and handle the appropriate methods if at runtime of their application it experiences a stopped service.&amp;nbsp; Again, pretty simple yet has a lot of value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Part of the GP service that checks service status:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;def reviewRunning(token):

&amp;nbsp;&amp;nbsp;&amp;nbsp; query_dict = { "f": "json", "token": token['token'] }&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp; # query your services url&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; jsonResponse = urllib.urlopen(URL, urllib.urlencode(query_dict))
&amp;nbsp;&amp;nbsp;&amp;nbsp; rooturl = agsurl + site + "/admin/services"
&amp;nbsp;&amp;nbsp;&amp;nbsp; rootresp = json.loads(urllib.urlopen(rooturl + "?f=json", urllib.urlencode(query_dict)).read())
&amp;nbsp;&amp;nbsp;&amp;nbsp; fldrs = rootresp['folders']
&amp;nbsp;&amp;nbsp;&amp;nbsp; for fldr in fldrs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fldrurl = agsurl + site + "/admin/services/" + fldr&amp;nbsp; 

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_dict = { "f": "json", "token": token['token'] }&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcresp = json.loads(urllib.urlopen(fldrurl + "?f=json", urllib.urlencode(query_dict)).read())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcs = svcresp['services']
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for svc in svcs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcname = svc['serviceName']
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svctype = svc['type']

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; query_dict = { "f": "json", "token": token['token'] }

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcstatusurl =&amp;nbsp; fldrurl + "/" + svcname + "." + svctype + "/status"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcstatusresp = json.loads(urllib.urlopen(svcstatusurl + "?f=json", urllib.urlencode(query_dict)).read())

&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; svcstatus = svcstatusresp['realTimeState']
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print svcname, svctype, svcstatus&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 22:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510974#M40151</guid>
      <dc:creator>JamesCrandall</dc:creator>
      <dc:date>2021-12-11T22:22:07Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510975#M40152</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I agree with Rebecca that being able to hide/encrypt or encapsulate the admin user credentials in a secure fashion is the most important piece that is missing. Once that is in place, being able to able to access secured services, https, service status and all others all become more useful. In fact looking at the this thread and the contributions, most of the rest has been achieved and folks are willing to share with the community.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:07:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510975#M40152</guid>
      <dc:creator>SubuSwaminathan1</dc:creator>
      <dc:date>2016-08-12T16:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: AGS admin scripting help</title>
      <link>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510976#M40153</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Have you found that services need time to stop or that ArcGIS Server needs to recover before the next stop or start request is sent in. I was testing the stop functionality with a large number of services and soon found that I need to introduce a delay if I can expect ArcGIS Server to respond to each request in a reliable fashion. So this meant that I had to increase the token's expiration time as well as insert a time delay to ensure that the server is ready to respond. Otherwise I get an urllib error saying that the process has timed out. Still early days in terms of using this in production in our org.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Subu&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Aug 2016 16:22:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/ags-admin-scripting-help/m-p/510976#M40153</guid>
      <dc:creator>SubuSwaminathan1</dc:creator>
      <dc:date>2016-08-12T16:22:48Z</dc:date>
    </item>
  </channel>
</rss>

