Skip to content

Instantly share code, notes, and snippets.

@mu88
Created March 1, 2018 16:16
Show Gist options
  • Save mu88/156a630b8f98fcfe8f4fe60448a3bbea to your computer and use it in GitHub Desktop.
Save mu88/156a630b8f98fcfe8f4fe60448a3bbea to your computer and use it in GitHub Desktop.
ArcPy - Create ArcGIS Server Connection File
import arcpy
servers = ['myServer1', 'myServer2', 'myServer3']
outdir = 'GIS Servers' # using 'GIS Servers' results in creating the AGS files in the 'GIS Servers' section of ArcCatalog (equivalent to '%appdata%\ESRI\Desktop10.5\ArcCatalog')
username = ''
password = ''
for server in servers:
out_name = server + ' (admin).ags'
server_url = 'https://' + server + '/arcgis/admin'
print "Creating '" + out_name + "'"
arcpy.mapping.CreateGISServerConnectionFile("ADMINISTER_GIS_SERVICES",
outdir,
out_name,
server_url,
"ARCGIS_SERVER",
username=username,
password=password)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment