diff --git a/scripted.groovy b/scripted.groovy
new file mode 100644
index 0000000..8815e73
--- /dev/null
+++ b/scripted.groovy
@@ -0,0 +1,158 @@
+#!groovy
+@Grab('org.yaml:snakeyaml:1.17')
+import jenkins.model.Jenkins;
+import jenkins.model.GlobalConfiguration
+import net.sf.json.JSONArray;
+import net.sf.json.JSONObject
+import org.yaml.snakeyaml.Yaml
+import io.jenkins.plugins.casc.ConfigurationAsCode
+import jenkins.security.UpdateSiteWarningsConfiguration
+
+Yaml parser = new Yaml()
+
+def casc = ConfigurationAsCode.get()
+def configPath = casc.getStandardConfig()[0]
+def symlFiles = new FileNameFinder().getFileNames(configPath, '**/*.syml', '.**/ **/.*')
+def configs = []
+symlFiles.each {
+    configs = configs + parser.load((it as File).text)
+}
+
+class Globals {
+    public static Boolean compareObjects( Object a, b) {
+        return Jenkins.XSTREAM.toXML(a) == Jenkins.XSTREAM.toXML(b)
+    }
+}
+
+class UpdateSiteWarnings {
+    UpdateSiteWarnings() {}
+    Boolean changed = false
+    def instance = Jenkins.instance
+    void configure(params) {
+        def config = GlobalConfiguration.all().get(UpdateSiteWarningsConfiguration.class)
+        def _config = new UpdateSiteWarningsConfiguration()
+
+        _config.configure(null, JSONObject.fromObject(params))
+        if (! Globals.compareObjects(config, _config)) {
+            config.configure(null, JSONObject.fromObject(params))
+            changed = true
+        }
+        _config = null
+    }
+}
+
+class CSP {
+    CSP() {}
+    Boolean changed = false
+    def instance = Jenkins.instance
+    void configure(param) {
+        String currentPolicy = System.getProperty("hudson.model.DirectoryBrowserSupport.CSP")
+        String newPolicy = param.policy.trim()
+        if ( currentPolicy != newPolicy ){
+            System.setProperty("hudson.model.DirectoryBrowserSupport.CSP", newPolicy)
+            changed = true
+        }
+    }
+}
+
+class GerritTrigger {
+    GerritTrigger() {}
+
+    def instance = Jenkins.instance
+    Boolean changed = false
+    def defaultServerParam = [
+        noConnectionOnStartup: false,
+        gerritBuildStartedVerifiedValue: 0,
+        gerritBuildSuccessfulVerifiedValue: 1,
+        gerritBuildFailedVerifiedValue: -1,
+        gerritBuildUnstableVerifiedValue: 0,
+        gerritBuildNotBuiltVerifiedValue: 0,
+        gerritBuildStartedCodeReviewValue: 0,
+        gerritBuildSuccessfulCodeReviewValue: 0,
+        gerritBuildFailedCodeReviewValue: 0,
+        gerritBuildUnstableCodeReviewValue: -1,
+        gerritBuildNotBuiltCodeReviewValue: 0,
+        gerritVerifiedCmdBuildStarted:
+            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
+        gerritVerifiedCmdBuildSuccessful:
+            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
+        gerritVerifiedCmdBuildFailed:
+            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
+        gerritVerifiedCmdBuildUnstable:
+            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
+        gerritVerifiedCmdBuildNotBuilt:
+            "gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' --verified <VERIFIED> --code-review <CODE_REVIEW>",
+        verdictCategories: [
+            [ verdictValue: 'Code-Review', verdictDescription: 'Code Review' ],
+            [ verdictValue: 'Verified', verdictDescription: 'Verified' ],
+        ]
+    ]
+
+    Boolean compareObjects( Object a, b) {
+        String aXML = Jenkins.XSTREAM.toXML(a).replaceAll(/\{AQA[^\}]+\}/) {
+                          hudson.util.Secret.decrypt(it) }
+        String bXML = Jenkins.XSTREAM.toXML(b).replaceAll(/\{AQA[^\}]+\}/) {
+                          hudson.util.Secret.decrypt(it) }
+        return aXML == bXML
+    }
+
+    void configure(params) {
+        if ( Jenkins.instance.pluginManager.activePlugins.find { it.shortName == "gerrit-trigger" } == null ) {
+            return
+        }
+        def gerritPlugin = Jenkins.instance.getPlugin(com.sonyericsson.hudson.plugins.gerrit.trigger.PluginImpl.class);
+
+        // Configure common parameters
+        def pluginConfig = gerritPlugin.getPluginConfig()
+        def _pluginConfig = new com.sonyericsson.hudson.plugins.gerrit.trigger.config.PluginConfig()
+
+        _pluginConfig.setValues(JSONArray.fromObject(params))
+        if (! compareObjects(pluginConfig, _pluginConfig)) {
+            pluginConfig.setValues(JSONArray.fromObject(params))
+            changed = true
+        }
+        _pluginConfig = null
+
+        // Configure servers
+        params.servers.each { _name, _params ->
+            def __params = defaultServerParam + _params
+            def values = JSONArray.fromObject(__params)
+            def server = gerritPlugin.getServer(_name)
+
+            if (! server) {
+                server = new com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer(
+                    _name, __params.noConnectionOnStartup)
+            }
+            def config = server.getConfig()
+            def _server = new com.sonyericsson.hudson.plugins.gerrit.trigger.GerritServer(
+                _name, __params.noConnectionOnStartup)
+            def _config = _server.getConfig()
+            _config.setValues(values)
+            _server.setConfig(_config)
+            if (! compareObjects(server, _server)) {
+                changed = true
+                if ( gerritPlugin.containsServer(_name) ) {
+                    gerritPlugin.removeServer(gerritPlugin.getServer(_name))
+                }
+                gerritPlugin.addServer(_server)
+                _server.start()
+                if (! __params.noConnectionOnStartup) {
+                    _server.startConnection()
+                }
+            }
+        }
+    }
+}
+
+configs.each { params ->
+    params.each { _name, _params ->
+        def clazz = Class.forName(_name)
+        if (clazz) {
+            def act = clazz.newInstance()
+            act.configure(_params)
+            if (act.changed) {
+                act.instance.save()
+            }
+        }
+    }
+}
