Friday, October 14, 2011

Update all ArcGIS Server Service properties at once

One question I have heard a lot for ArcGIS Server is how do I modify the configuration settings for all of my services at once. For example, let’s say I wanted to change my MinInstances across the board to 0. Or better yet set my MaxInstances for all services to 50. The solution I found for this is PowerShell (Windows only, sorry my Linux friends). I’m using the XML editing capabilities of PowerShell to find the right configuration node and change it. This works recursively on a folder for all files with the extension “.cfg”

Here is the PowerShell script:

$cfgProperty = "MaxInstances"
$newVal = 50
$folder = "C:\Program Files\ArcGIS\Server10.0\server\user\cfg"
$files = Get-childItem –filter *.cfg -path $folder -recurse

foreach($file in $files)
{
$xmldata = [xml](Get-Content $file.fullname)
$node = $xmldata.SelectSingleNode("ServerObjectConfiguration/" + $cfgProperty)
if($node -ne $null) { $node.set_InnerText($newVal) }
$xmldata.Save($file.FullName)
}

All you need to do is change the first three lines for your system. Set as follows.

  • $cfgProperty – Set this to the exact configuration name that you want to change. This is case sensitive. I recommend opening one of your cfg files and doing a Copy/Paste.
  • $newVal – Set this to whatever you want the value for the target property to be.
  • $folder – Set this to the location of your .cfg files.

I just modify the script and copy and paste it into the Windows PowerShell command prompt. Once you execute the code just restart the SOM service (ArcGIS Server Object Manager) and all your settings will be applied.

Hey Linux people. Feel free to add your own script to do this as a comment!

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. you’ve made some good points there. it’s a good idea! Please visit http://goo.gl/NeNtws

    ReplyDelete