public static void ExportTestSettings(
            // 20140720
            SettingsCmdletBase cmdlet,
            // ISettingsCmdletBaseDataObject cmdlet,
            string path,
            string[] variableNames)
        {
            try {
                var rootElement = new XElement("variables");
                
                foreach (var variableName in variableNames) {
                    var variable = cmdlet.SessionState.PSVariable.Get(variableName);
                    try {
                        if (string.IsNullOrEmpty(variable.Name)) continue;
                        // if (null != variable.Name && string.Empty != variable.Name) {
                        var variableElement =
                            new XElement("variable",
                                new XAttribute("name", variable.Name),
                                new XAttribute("value", variable.Value));
                        rootElement.Add(variableElement);

                        /*
                        if (!string.IsNullOrEmpty(variable.Name)) {
                        // if (null != variable.Name && string.Empty != variable.Name) {
                            XElement variableElement =
                                new XElement("variable",
                                             new XAttribute("name", variable.Name),
                                             new XAttribute("value", variable.Value));
                            rootElement.Add(variableElement);
                        }
                        */
                    }
                    catch (Exception eVariable) {
                        // 20140720
//                        cmdlet.WriteError(
//                            cmdlet,
//                            "Unable to export variable '" +
//                            variableName +
//                            "'.",
//                            "FailedToExportVariable",
//                            ErrorCategory.InvalidArgument,
//                            false);
                        throw new Exception(
                            "Unable to export variable '" +
                            variableName +
                            "'.");
                    }
                }
                
                var document = new XDocument();
                document.Add(rootElement);
                document.Save(path);
            }
            catch (Exception eCreateDocument) {
                // 20140720
//                cmdlet.WriteError(
//                    cmdlet,
//                    "Unable to save XML report to the file '" +
//                    path +
//                    "'. " + 
//                    eCreateDocument.Message,
//                    "FailedToSaveReport",
//                    ErrorCategory.InvalidOperation,
//                    true);
                throw new Exception(
                    "Unable to save XML report to the file '" +
                    path +
                    "'. " + 
                    eCreateDocument.Message);
            }
        }
        public static void ExportTestSettings(
            // 20140720
            SettingsCmdletBase cmdlet,
            // ISettingsCmdletBaseDataObject cmdlet,
            string path,
            string[] variableNames)
        {
            try {
                var rootElement = new XElement("variables");

                foreach (var variableName in variableNames)
                {
                    var variable = cmdlet.SessionState.PSVariable.Get(variableName);
                    try {
                        if (string.IsNullOrEmpty(variable.Name))
                        {
                            continue;
                        }
                        // if (null != variable.Name && string.Empty != variable.Name) {
                        var variableElement =
                            new XElement("variable",
                                         new XAttribute("name", variable.Name),
                                         new XAttribute("value", variable.Value));
                        rootElement.Add(variableElement);

                        /*
                         * if (!string.IsNullOrEmpty(variable.Name)) {
                         * // if (null != variable.Name && string.Empty != variable.Name) {
                         *  XElement variableElement =
                         *      new XElement("variable",
                         *                   new XAttribute("name", variable.Name),
                         *                   new XAttribute("value", variable.Value));
                         *  rootElement.Add(variableElement);
                         * }
                         */
                    }
                    catch (Exception eVariable) {
                        // 20140720
//                        cmdlet.WriteError(
//                            cmdlet,
//                            "Unable to export variable '" +
//                            variableName +
//                            "'.",
//                            "FailedToExportVariable",
//                            ErrorCategory.InvalidArgument,
//                            false);
                        throw new Exception(
                                  "Unable to export variable '" +
                                  variableName +
                                  "'.");
                    }
                }

                var document = new XDocument();
                document.Add(rootElement);
                document.Save(path);
            }
            catch (Exception eCreateDocument) {
                // 20140720
//                cmdlet.WriteError(
//                    cmdlet,
//                    "Unable to save XML report to the file '" +
//                    path +
//                    "'. " +
//                    eCreateDocument.Message,
//                    "FailedToSaveReport",
//                    ErrorCategory.InvalidOperation,
//                    true);
                throw new Exception(
                          "Unable to save XML report to the file '" +
                          path +
                          "'. " +
                          eCreateDocument.Message);
            }
        }