/// <summary> /// <para> /// Base on parametersetName to retrieve ciminstances /// </para> /// </summary> /// <param name="cmdlet"><see cref="GetCimInstanceCommand"/> object</param> public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet) { DebugHelper.WriteLogEx(); IEnumerable <string> computerNames = ConstValue.GetComputerNames( GetComputerName(cmdlet)); List <CimSessionProxy> proxys = new List <CimSessionProxy>(); switch (cmdlet.ParameterSetName) { case CimBaseCommand.CimInstanceComputerSet: foreach (string computerName in computerNames) { proxys.Add(CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet)); } break; case CimBaseCommand.CimInstanceSessionSet: foreach (CimSession session in GetCimSession(cmdlet)) { proxys.Add(CreateSessionProxy(session, cmdlet)); } break; default: break; } switch (cmdlet.ParameterSetName) { case CimBaseCommand.CimInstanceComputerSet: case CimBaseCommand.CimInstanceSessionSet: string nameSpace = null; if (cmdlet.ResourceUri != null) { nameSpace = GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace; } else { nameSpace = ConstValue.GetNamespace(GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace); } string target = cmdlet.CimInstance.ToString(); foreach (CimSessionProxy proxy in proxys) { if (!cmdlet.ShouldProcess(target, action)) { return; } proxy.DeleteInstanceAsync(nameSpace, cmdlet.CimInstance); } break; case CimBaseCommand.QueryComputerSet: case CimBaseCommand.QuerySessionSet: GetCimInstanceInternal(cmdlet); break; default: break; } }
/// <summary> /// <para> /// Base on parametersetName to retrieve ciminstances /// </para> /// </summary> /// <param name="cmdlet"><see cref="GetCimInstanceCommand"/> object</param> public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet) { DebugHelper.WriteLogEx(); IEnumerable<string> computerNames = ConstValue.GetComputerNames( GetComputerName(cmdlet)); List<CimSessionProxy> proxys = new List<CimSessionProxy>(); switch (cmdlet.ParameterSetName) { case CimBaseCommand.CimInstanceComputerSet: foreach (string computerName in computerNames) { proxys.Add(CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet)); } break; case CimBaseCommand.CimInstanceSessionSet: foreach (CimSession session in GetCimSession(cmdlet)) { proxys.Add(CreateSessionProxy(session, cmdlet)); } break; default: break; } switch (cmdlet.ParameterSetName) { case CimBaseCommand.CimInstanceComputerSet: case CimBaseCommand.CimInstanceSessionSet: string nameSpace = null; if(cmdlet.ResourceUri != null ) { nameSpace = GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace; } else { nameSpace = ConstValue.GetNamespace(GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace); } string target = cmdlet.CimInstance.ToString(); foreach (CimSessionProxy proxy in proxys) { if (!cmdlet.ShouldProcess(target, action)) { return; } proxy.DeleteInstanceAsync(nameSpace, cmdlet.CimInstance); } break; case CimBaseCommand.QueryComputerSet: case CimBaseCommand.QuerySessionSet: GetCimInstanceInternal(cmdlet); break; default: break; } }
/// <summary> /// <para> /// Set <see cref="CimSessionProxy"/> properties /// </para> /// </summary> /// <param name="proxy"></param> /// <param name="cmdlet"></param> private void SetSessionProxyProperties( ref CimSessionProxy proxy, CimBaseCommand cmdlet) { if (cmdlet is GetCimInstanceCommand) { GetCimInstanceCommand getCimInstance = cmdlet as GetCimInstanceCommand; proxy.KeyOnly = getCimInstance.KeyOnly; proxy.Shallow = getCimInstance.Shallow; proxy.OperationTimeout = getCimInstance.OperationTimeoutSec; if (getCimInstance.ResourceUri != null) { proxy.ResourceUri = getCimInstance.ResourceUri; } } else if (cmdlet is RemoveCimInstanceCommand) { RemoveCimInstanceCommand removeCimInstance = cmdlet as RemoveCimInstanceCommand; proxy.OperationTimeout = removeCimInstance.OperationTimeoutSec; if (removeCimInstance.ResourceUri != null) { proxy.ResourceUri = removeCimInstance.ResourceUri; } CimRemoveCimInstanceContext context = new CimRemoveCimInstanceContext( ConstValue.GetNamespace(removeCimInstance.Namespace), proxy); proxy.ContextObject = context; } else if (cmdlet is SetCimInstanceCommand) { SetCimInstanceCommand setCimInstance = cmdlet as SetCimInstanceCommand; proxy.OperationTimeout = setCimInstance.OperationTimeoutSec; if (setCimInstance.ResourceUri != null) { proxy.ResourceUri = setCimInstance.ResourceUri; } CimSetCimInstanceContext context = new CimSetCimInstanceContext( ConstValue.GetNamespace(setCimInstance.Namespace), setCimInstance.Property, proxy, cmdlet.ParameterSetName, setCimInstance.PassThru); proxy.ContextObject = context; } }
public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet) { string @namespace; DebugHelper.WriteLogEx(); IEnumerable <string> computerNames = ConstValue.GetComputerNames(CimGetInstance.GetComputerName(cmdlet)); List <CimSessionProxy> cimSessionProxies = new List <CimSessionProxy>(); string parameterSetName = cmdlet.ParameterSetName; string str = parameterSetName; if (parameterSetName != null) { if (str == "CimInstanceComputerSet") { foreach (string computerName in computerNames) { cimSessionProxies.Add(base.CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet)); } } else { if (str == "CimInstanceSessionSet") { CimSession[] cimSession = CimGetInstance.GetCimSession(cmdlet); for (int i = 0; i < (int)cimSession.Length; i++) { CimSession cimSession1 = cimSession[i]; cimSessionProxies.Add(base.CreateSessionProxy(cimSession1, cmdlet)); } } } } string parameterSetName1 = cmdlet.ParameterSetName; string str1 = parameterSetName1; if (parameterSetName1 != null) { if (str1 == "CimInstanceComputerSet" || str1 == "CimInstanceSessionSet") { if (cmdlet.ResourceUri == null) { @namespace = ConstValue.GetNamespace(CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace); } else { @namespace = CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace; } string str2 = cmdlet.CimInstance.ToString(); foreach (CimSessionProxy cimSessionProxy in cimSessionProxies) { if (cmdlet.ShouldProcess(str2, "Remove-CimInstance")) { cimSessionProxy.DeleteInstanceAsync(@namespace, cmdlet.CimInstance); } else { return; } } } else { if (str1 == "QueryComputerSet" || str1 == "QuerySessionSet") { base.GetCimInstanceInternal(cmdlet); } else { return; } } } }
public void RemoveCimInstance(RemoveCimInstanceCommand cmdlet) { string @namespace; DebugHelper.WriteLogEx(); IEnumerable<string> computerNames = ConstValue.GetComputerNames(CimGetInstance.GetComputerName(cmdlet)); List<CimSessionProxy> cimSessionProxies = new List<CimSessionProxy>(); string parameterSetName = cmdlet.ParameterSetName; string str = parameterSetName; if (parameterSetName != null) { if (str == "CimInstanceComputerSet") { foreach (string computerName in computerNames) { cimSessionProxies.Add(base.CreateSessionProxy(computerName, cmdlet.CimInstance, cmdlet)); } } else { if (str == "CimInstanceSessionSet") { CimSession[] cimSession = CimGetInstance.GetCimSession(cmdlet); for (int i = 0; i < (int)cimSession.Length; i++) { CimSession cimSession1 = cimSession[i]; cimSessionProxies.Add(base.CreateSessionProxy(cimSession1, cmdlet)); } } } } string parameterSetName1 = cmdlet.ParameterSetName; string str1 = parameterSetName1; if (parameterSetName1 != null) { if (str1 == "CimInstanceComputerSet" || str1 == "CimInstanceSessionSet") { if (cmdlet.ResourceUri == null) { @namespace = ConstValue.GetNamespace(CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace); } else { @namespace = CimGetInstance.GetCimInstanceParameter(cmdlet).CimSystemProperties.Namespace; } string str2 = cmdlet.CimInstance.ToString(); foreach (CimSessionProxy cimSessionProxy in cimSessionProxies) { if (cmdlet.ShouldProcess(str2, "Remove-CimInstance")) { cimSessionProxy.DeleteInstanceAsync(@namespace, cmdlet.CimInstance); } else { return; } } } else { if (str1 == "QueryComputerSet" || str1 == "QuerySessionSet") { base.GetCimInstanceInternal(cmdlet); } else { return; } } } }