/// <summary> /// Generates a Computer Parameter object from anything /// </summary> /// <param name="InputObject"></param> public ComputerParameter(object InputObject) { if (InputObject == null) { throw new ArgumentException("Input must not be null"); } PSObject input = new PSObject(InputObject); this.InputObject = InputObject; string key = ""; foreach (string name in input.TypeNames) { if (_PropertyMapping.ContainsKey(name.ToLower())) { key = name.ToLower(); break; } if (name.ToLower() == "microsoft.sqlserver.management.smo.server") { Type = ComputerParameterInputType.SMOServer; } } if (key == "") { throw new ArgumentException(String.Format("Could not interpret {0}", InputObject.GetType().FullName)); } foreach (string property in _PropertyMapping[key]) { if (input.Properties[property] != null && input.Properties[property].Value != null && !String.IsNullOrEmpty(input.Properties[property].Value.ToString())) { ComputerName = input.Properties[property].Value.ToString(); break; } } }
/// <summary> /// Creates a Computer Parameter from a CimSession /// </summary> /// <param name="Session">The session to create the parameter from</param> public ComputerParameter(CimSession Session) { InputObject = Session; ComputerName = Session.ComputerName; Type = ComputerParameterInputType.CimSession; }
/// <summary> /// Creates a Computer Parameter from a Session Container object. /// </summary> /// <param name="Container">A container that can be used to store multiple types of session objects in parallel.</param> public ComputerParameter(ComputerManagement.SessionContainer Container) { InputObject = Container; ComputerName = Container.ComputerName; Type = ComputerParameterInputType.Container; }