예제 #1
0
 protected override void ProcessRecord()
 {
     if (isInitialized())
     {
         try
         {
             iControl.ManagementDBVariableVariableNameValue[] variables = new iControl.ManagementDBVariableVariableNameValue[1];
             variables[0]       = new iControl.ManagementDBVariableVariableNameValue();
             variables[0].name  = _name;
             variables[0].value = _value;
             if (variableExists(_name))
             {
                 // modify
                 GetiControl().ManagementDBVariable.modify(variables);
             }
             else
             {
                 // create
                 GetiControl().ManagementDBVariable.create(variables);
             }
             ManagementDatabaseItem mdbi = new ManagementDatabaseItem();
             mdbi.Name  = _name;
             mdbi.Value = _value;
             WriteObject(mdbi);
         }
         catch (Exception ex)
         {
             ErrorRecord er = new ErrorRecord(ex, "2", ErrorCategory.OpenError, "error");
             WriteError(er);
         }
     }
     else
     {
         handleNotInitialized();
     }
 }
예제 #2
0
        protected override void ProcessRecord()
        {
            if (isInitialized())
            {
                try
                {
                    iControl.ManagementDBVariableVariableNameValue [] var_list = GetiControl().ManagementDBVariable.get_list();

                    for (int i = 0; i < var_list.Length; i++)
                    {
                        bool bMatch = true;
                        if (null != _name)
                        {
                            bMatch = (true == matchString(var_list[i].name, _name, RegexOptions.IgnoreCase));
                        }

                        if (bMatch)
                        {
                            ManagementDatabaseItem mdbi = new ManagementDatabaseItem();
                            mdbi.Name  = var_list[i].name;
                            mdbi.Value = var_list[i].value;
                            WriteObject(mdbi);
                        }
                    }
                }
                catch (Exception ex)
                {
                    ErrorRecord er = new ErrorRecord(ex, "2", ErrorCategory.OpenError, "error");
                    WriteError(er);
                }
            }
            else
            {
                handleNotInitialized();
            }
        }