/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (connectionuri != null) { try { // always in the format http://server:port/applicationname string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } string crtComputerName = computername; if (crtComputerName == null) { crtComputerName = "localhost"; } if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(this.SessionState.Drive.Current.Name + ":" + WSManStringLiterals.DefaultPathSeparator + crtComputerName, StringComparison.OrdinalIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("ConnectFailure"), false, computername); } helper.CreateWsManConnection(ParameterSetName, connectionuri, port, computername, applicationname, usessl.IsPresent, Authentication, sessionoption, Credential, CertificateThumbprint); }
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if (this.computername == null) { this.computername = "localhost"; } if (base.SessionState.Path.CurrentProviderLocation("WSMan").Path.StartsWith(string.Concat("WSMan:", (char)92, this.computername), StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, this.computername); } if (this.computername.Equals("localhost", StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("LocalHost"), false, this.computername); } object obj = wSManHelper.RemoveFromDictionary(this.computername); if (obj == null) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, this.computername); return; } else { this.Dispose(obj); return; } }
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if (this.computername == null) { this.computername = "localhost"; } if (base.SessionState.Path.CurrentProviderLocation("WSMan").Path.StartsWith(string.Concat("WSMan:", (char)92, this.computername), StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, this.computername); } if (this.computername.Equals("localhost", StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("LocalHost"), false, this.computername); } object obj = wSManHelper.RemoveFromDictionary(this.computername); if (obj == null) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, this.computername); return; } else { this.Dispose(obj); return; } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (computername == null) { computername = "localhost"; } if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(WSManStringLiterals.rootpath + ":" + WSManStringLiterals.DefaultPathSeparator + computername, StringComparison.OrdinalIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, computername); } if (computername.Equals("localhost", StringComparison.OrdinalIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("LocalHost"), false, computername); } object _ws = helper.RemoveFromDictionary(computername); if (_ws != null) { Dispose(_ws); } else { helper.AssertError(helper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, computername); } }
private void DisableClientSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); if (m_SessionObj is null) { return; } try { string result = m_SessionObj.Get(helper.CredSSP_RUri, 0); XmlDocument resultopxml = new XmlDocument(); string inputXml = null; resultopxml.LoadXml(result); XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable); nsmgr.AddNamespace("cfg", helper.CredSSP_XMLNmsp); XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr); if (!(xNode is null)) { inputXml = @"<cfg:Auth xmlns:cfg=""http://schemas.microsoft.com/wbem/wsman/1/config/client/auth""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>"; } else { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } m_SessionObj.Put(helper.CredSSP_RUri, inputXml, 0); if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) { this.DeleteUserDelegateSettings(); } else { ThreadStart start = new ThreadStart(this.DeleteUserDelegateSettings); Thread thread = new Thread(start); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } if (!helper.ValidateCreadSSPRegistryRetry(false, null, applicationname)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null); } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (proxyauthentication.Equals(ProxyAuthentication.Basic) || proxyauthentication.Equals(ProxyAuthentication.Digest)) { if (_proxycredential == null) { InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred")); ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null); WriteError(er); return; } } if ((_proxycredential != null) && (proxyauthentication == 0)) { InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth")); ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null); WriteError(er); return; } //Creating the Session Object SessionOption objSessionOption = new SessionOption(); objSessionOption.SPNPort = spnport; objSessionOption.UseUtf16 = useutf16; objSessionOption.SkipCNCheck = skipcncheck; objSessionOption.SkipCACheck = skipcacheck; objSessionOption.OperationTimeout = operationtimeout; objSessionOption.SkipRevocationCheck = skiprevocationcheck; //Proxy Settings objSessionOption.ProxyAccessType = _proxyaccesstype; objSessionOption.ProxyAuthentication = proxyauthentication; if (noencryption) { objSessionOption.UseEncryption = false; } if (_proxycredential != null) { NetworkCredential nwCredentials = _proxycredential.GetNetworkCredential(); objSessionOption.ProxyCredential = nwCredentials; } WriteObject(objSessionOption); } //End BeginProcessing()
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); String query = helper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery"); String caption = helper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption"); if (!force && !ShouldContinue(query, caption)) { return; } QuickConfigRemoting(true); QuickConfigRemoting(false); }//End BeginProcessing()
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if (this.connectionuri != null) { try { string[] strArrays = new string[1]; object[] objArray = new object[4]; objArray[0] = ":"; objArray[1] = this.port; objArray[2] = "/"; objArray[3] = this.applicationname; strArrays[0] = string.Concat(objArray); string[] strArrays1 = this.connectionuri.OriginalString.Split(strArrays, StringSplitOptions.None); string[] strArrays2 = new string[1]; strArrays2[0] = "//"; string[] strArrays3 = strArrays1[0].Split(strArrays2, StringSplitOptions.None); this.computername = strArrays3[1].Trim(); } catch (IndexOutOfRangeException indexOutOfRangeException) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, this.connectionuri); } } string str = this.computername; if (str == null) { str = "localhost"; } object[] name = new object[4]; name[0] = base.SessionState.Drive.Current.Name; name[1] = ":"; name[2] = (char)92; name[3] = str; if (base.SessionState.Path.CurrentProviderLocation("WSMan").Path.StartsWith(string.Concat(name), StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("ConnectFailure"), false, this.computername); } wSManHelper.CreateWsManConnection(base.ParameterSetName, this.connectionuri, this.port, this.computername, this.applicationname, this.usessl.IsPresent, this.Authentication, this.sessionoption, this.Credential, this.CertificateThumbprint); }
private void DisableServerSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); if (m_SessionObj == null) { return; } try { string result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0); XmlDocument resultopxml = new XmlDocument(); string inputXml = null; resultopxml.LoadXml(result); XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable); nsmgr.AddNamespace("cfg", helper.Service_CredSSP_XMLNmsp); XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr); if (!(xNode == null)) { inputXml = string.Format(CultureInfo.InvariantCulture, @"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>", helper.Service_CredSSP_XMLNmsp); } else { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0); } finally { if (!string.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, null); } if (m_SessionObj != null) { Dispose(m_SessionObj); } } }
private void DisableServerSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); if (null == m_SessionObj) { return; } try { string result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0); XmlDocument resultopxml = new XmlDocument(); string inputXml = null; resultopxml.LoadXml(result); XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable); nsmgr.AddNamespace("cfg", helper.Service_CredSSP_XMLNmsp); XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr); if (!(xNode == null)) { inputXml = string.Format(CultureInfo.InvariantCulture, @"<cfg:Auth xmlns:cfg=""{0}""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>", helper.Service_CredSSP_XMLNmsp); } else { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } m_SessionObj.Put(helper.Service_CredSSP_Uri, inputXml, 0); } finally { if (!String.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, null); } if (m_SessionObj != null) { Dispose(m_SessionObj); } } }
protected override void ProcessRecord() { WSManHelper wSManHelper = new WSManHelper(this); IWSManEx wSManClass = (IWSManEx)(new WSManClass()); wSManHelper.WSManOp = "remove"; IWSManSession wSManSession = null; try { string str = wSManHelper.CreateConnectionString(this.connectionuri, this.port, this.computername, this.applicationname); if (this.connectionuri != null) { try { string[] strArrays = new string[1]; object[] objArray = new object[4]; objArray[0] = ":"; objArray[1] = this.port; objArray[2] = "/"; objArray[3] = this.applicationname; strArrays[0] = string.Concat(objArray); string[] strArrays1 = this.connectionuri.OriginalString.Split(strArrays, StringSplitOptions.None); string[] strArrays2 = new string[1]; strArrays2[0] = "//"; string[] strArrays3 = strArrays1[0].Split(strArrays2, StringSplitOptions.None); this.computername = strArrays3[1].Trim(); } catch (IndexOutOfRangeException indexOutOfRangeException) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, this.connectionuri); } } wSManHelper.InitializeResourceLocator(this.optionset, this.selectorset, null, null, wSManClass, this.resourceuri); wSManSession = wSManHelper.CreateSessionObject(wSManClass, this.Authentication, this.sessionoption, this.Credential, str, this.CertificateThumbprint, this.usessl.IsPresent); string uRIWithFilter = wSManHelper.GetURIWithFilter(this.resourceuri.ToString(), null, this.selectorset, wSManHelper.WSManOp); try { wSManSession.Delete(uRIWithFilter, 0); } catch (Exception exception1) { Exception exception = exception1; wSManHelper.AssertError(exception.Message, false, this.computername); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, this.resourceuri); } if (!string.IsNullOrEmpty(wSManClass.Error)) { wSManHelper.AssertError(wSManClass.Error, true, this.resourceuri); } if (wSManSession != null) { this.Dispose(wSManSession); } } }
private void DisableServerSideSettings() { WSManHelper wSManHelper = new WSManHelper(this); IWSManSession wSManSession = base.CreateWSManSession(); if (wSManSession != null) { try { string str = wSManSession.Get(wSManHelper.Service_CredSSP_Uri, 0); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(str); XmlNamespaceManager xmlNamespaceManagers = new XmlNamespaceManager(xmlDocument.NameTable); xmlNamespaceManagers.AddNamespace("cfg", wSManHelper.Service_CredSSP_XMLNmsp); XmlNode xmlNodes = xmlDocument.SelectSingleNode(wSManHelper.CredSSP_SNode, xmlNamespaceManagers); if (xmlNodes == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, wSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); } else { object[] serviceCredSSPXMLNmsp = new object[1]; serviceCredSSPXMLNmsp[0] = wSManHelper.Service_CredSSP_XMLNmsp; string str1 = string.Format(CultureInfo.InvariantCulture, "<cfg:Auth xmlns:cfg=\"{0}\"><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>", serviceCredSSPXMLNmsp); wSManSession.Put(wSManHelper.Service_CredSSP_Uri, str1, 0); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, null); } if (wSManSession != null) { this.Dispose(wSManSession); } } return; } else { return; } }
private void DisableClientSideSettings() { WSManHelper helper = new WSManHelper(this); IWSManSession m_SessionObj = CreateWSManSession(); if (null == m_SessionObj) { return; } try { string result = m_SessionObj.Get(helper.CredSSP_RUri, 0); XmlDocument resultopxml = new XmlDocument(); string inputXml = null; resultopxml.LoadXml(result); XmlNamespaceManager nsmgr = new XmlNamespaceManager(resultopxml.NameTable); nsmgr.AddNamespace("cfg", helper.CredSSP_XMLNmsp); XmlNode xNode = resultopxml.SelectSingleNode(helper.CredSSP_SNode, nsmgr); if (!(xNode == null)) { inputXml = @"<cfg:Auth xmlns:cfg=""http://schemas.microsoft.com/wbem/wsman/1/config/client/auth""><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>"; } else { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } m_SessionObj.Put(helper.CredSSP_RUri, inputXml, 0); #if !CORECLR if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) { this.DeleteUserDelegateSettings(); } else { ThreadStart start = new ThreadStart(this.DeleteUserDelegateSettings); Thread thread = new Thread(start); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } #else { ThreadStart start = new ThreadStart(this.DeleteUserDelegateSettings); Thread thread = new Thread(start); thread.Start(); thread.Join(); } #endif if (!helper.ValidateCreadSSPRegistryRetry(false, null, applicationname)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null); } } catch (System.Xml.XPath.XPathException ex) { ErrorRecord er = new ErrorRecord(ex, "XpathException", ErrorCategory.InvalidOperation, null); WriteError(er); } finally { if (!String.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, null); } if (m_SessionObj != null) Dispose(m_SessionObj); } }
/// <summary> /// ProcessRecord method. /// </summary> protected override void ProcessRecord() { IWSManSession m_session = null; IWSManEx m_wsmanObject = (IWSManEx)new WSManClass(); helper = new WSManHelper(this); helper.WSManOp = "Get"; string connectionStr = null; connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname); if (connectionuri != null) { try { //in the format http(s)://server[:port/applicationname] string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } try { IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, fragment, dialect, m_wsmanObject, resourceuri); m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent); if (!enumerate) { XmlDocument xmldoc = new XmlDocument(); try { xmldoc.LoadXml(m_session.Get(m_resource, 0)); } catch(XmlException ex) { helper.AssertError(ex.Message, false, computername); } if (!string.IsNullOrEmpty(fragment)) { WriteObject(xmldoc.FirstChild.LocalName + "=" + xmldoc.FirstChild.InnerText); } else { WriteObject(xmldoc.FirstChild); } } else { try { ReturnEnumeration(m_wsmanObject, m_resource, m_session); } catch (Exception ex) { helper.AssertError(ex.Message, false, computername); } } } finally { if (!String.IsNullOrEmpty(m_wsmanObject.Error)) { helper.AssertError(m_wsmanObject.Error, true, resourceuri); } if (!String.IsNullOrEmpty(m_session.Error)) { helper.AssertError(m_session.Error, true, resourceuri); } if (m_session != null) Dispose(m_session); } }
private void DisableClientSideSettings() { WSManHelper wSManHelper = new WSManHelper(this); IWSManSession wSManSession = base.CreateWSManSession(); if (wSManSession != null) { try { try { string str = wSManSession.Get(wSManHelper.CredSSP_RUri, 0); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(str); XmlNamespaceManager xmlNamespaceManagers = new XmlNamespaceManager(xmlDocument.NameTable); xmlNamespaceManagers.AddNamespace("cfg", wSManHelper.CredSSP_XMLNmsp); XmlNode xmlNodes = xmlDocument.SelectSingleNode(wSManHelper.CredSSP_SNode, xmlNamespaceManagers); if (xmlNodes == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, wSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); return; } else { string str1 = "<cfg:Auth xmlns:cfg=\"http://schemas.microsoft.com/wbem/wsman/1/config/client/auth\"><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>"; wSManSession.Put(wSManHelper.CredSSP_RUri, str1, 0); if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) { ThreadStart threadStart = new ThreadStart(this.DeleteUserDelegateSettings); Thread thread = new Thread(threadStart); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } else { this.DeleteUserDelegateSettings(); } if (!wSManHelper.ValidateCreadSSPRegistryRetry(false, null, "wsman")) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null); } } } catch (XPathException xPathException1) { XPathException xPathException = xPathException1; ErrorRecord errorRecord1 = new ErrorRecord(xPathException, "XpathException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord1); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, null); } if (wSManSession != null) { this.Dispose(wSManSession); } } return; } else { return; } }
/// <summary> /// Method to begin processing. /// </summary> protected override void BeginProcessing() { // If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); IWSManSession m_SessionObj = null; try { IWSManEx wsmanObject = (IWSManEx) new WSManClass(); m_SessionObj = (IWSManSession)wsmanObject.CreateSession(null, 0, null); string result = m_SessionObj.Get(helper.CredSSP_RUri, 0); XmlNode node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp); if (node == null) { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } // The application name MUST be "wsman" as wsman got approval from security // folks who suggested to register the SPN with name "wsman". const string applicationname = "wsman"; string credsspResult = GetDelegateSettings(applicationname); if (string.IsNullOrEmpty(credsspResult)) { WriteObject(helper.GetResourceMsgFromResourcetext("NoDelegateFreshCred")); } else { WriteObject(helper.GetResourceMsgFromResourcetext("DelegateFreshCred") + credsspResult); } // Get the server side settings result = m_SessionObj.Get(helper.Service_CredSSP_Uri, 0); node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.Service_CredSSP_XMLNmsp); if (node == null) { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } if (node.InnerText.Equals("true", StringComparison.OrdinalIgnoreCase)) { WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceConfigured")); } else { WriteObject(helper.GetResourceMsgFromResourcetext("CredSSPServiceNotConfigured")); } } catch (UnauthorizedAccessException ex) { ErrorRecord er = new ErrorRecord(ex, "UnauthorizedAccess", ErrorCategory.PermissionDenied, null); WriteError(er); } catch (SecurityException ex) { ErrorRecord er = new ErrorRecord(ex, "SecurityException", ErrorCategory.InvalidOperation, null); WriteError(er); } catch (ArgumentException ex) { ErrorRecord er = new ErrorRecord(ex, "InvalidArgument", ErrorCategory.InvalidOperation, null); WriteError(er); } catch (System.Xml.XPath.XPathException ex) { ErrorRecord er = new ErrorRecord(ex, "XPathException", ErrorCategory.InvalidOperation, null); WriteError(er); } finally { if (!string.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, null); } if (m_SessionObj != null) { Dispose(m_SessionObj); } } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { helper = new WSManHelper(this ); helper.WSManOp = "new"; connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname); if (connectionuri != null) { try { //in the format http(s)://server[:port/applicationname] string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } }//End BeginProcessing()
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if ((this.proxyauthentication.Equals(ProxyAuthentication.Basic) || this.proxyauthentication.Equals(ProxyAuthentication.Digest)) && this._proxycredential == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(wSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred")); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, "InvalidOperationException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); return; } else { if (this._proxycredential == null || this.proxyauthentication != 0) { SessionOption sessionOption = new SessionOption(); sessionOption.SPNPort = this.spnport; sessionOption.UseUtf16 = this.useutf16; sessionOption.SkipCNCheck = this.skipcncheck; sessionOption.SkipCACheck = this.skipcacheck; sessionOption.OperationTimeout = this.operationtimeout; sessionOption.SkipRevocationCheck = this.skiprevocationcheck; sessionOption.ProxyAccessType = this._proxyacesstype; sessionOption.ProxyAuthentication = this.proxyauthentication; if (this.noencryption) { sessionOption.UseEncryption = false; } if (this._proxycredential != null) { NetworkCredential networkCredential = this._proxycredential.GetNetworkCredential(); sessionOption.ProxyCredential = networkCredential; } base.WriteObject(sessionOption); return; } else { InvalidOperationException invalidOperationException1 = new InvalidOperationException(wSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth")); ErrorRecord errorRecord1 = new ErrorRecord(invalidOperationException1, "InvalidOperationException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord1); return; } } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (proxyauthentication.Equals(ProxyAuthentication.Basic) || proxyauthentication.Equals(ProxyAuthentication.Digest)) { if (_proxycredential == null) { InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred")); ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null); WriteError(er); return; } } if ((_proxycredential != null) && (proxyauthentication == 0)) { InvalidOperationException ex = new InvalidOperationException(helper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth")); ErrorRecord er = new ErrorRecord(ex, "InvalidOperationException", ErrorCategory.InvalidOperation, null); WriteError(er); return; } //Creating the Session Object SessionOption objSessionOption = new SessionOption(); objSessionOption.SPNPort = spnport; objSessionOption.UseUtf16 = useutf16; objSessionOption.SkipCNCheck = skipcncheck; objSessionOption.SkipCACheck = skipcacheck; objSessionOption.OperationTimeout = operationtimeout; objSessionOption.SkipRevocationCheck = skiprevocationcheck; //Proxy Settings objSessionOption.ProxyAccessType = _proxyacesstype; objSessionOption.ProxyAuthentication = proxyauthentication; if (noencryption) { objSessionOption.UseEncryption = false; } if (_proxycredential != null) { NetworkCredential nwCredentials = _proxycredential.GetNetworkCredential(); objSessionOption.ProxyCredential = nwCredentials; } WriteObject(objSessionOption); }//End BeginProcessing()
private void DisableServerSideSettings() { WSManHelper wSManHelper = new WSManHelper(this); IWSManSession wSManSession = base.CreateWSManSession(); if (wSManSession != null) { try { string str = wSManSession.Get(wSManHelper.Service_CredSSP_Uri, 0); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(str); XmlNamespaceManager xmlNamespaceManagers = new XmlNamespaceManager(xmlDocument.NameTable); xmlNamespaceManagers.AddNamespace("cfg", wSManHelper.Service_CredSSP_XMLNmsp); XmlNode xmlNodes = xmlDocument.SelectSingleNode(wSManHelper.CredSSP_SNode, xmlNamespaceManagers); if (xmlNodes == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, wSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); } else { object[] serviceCredSSPXMLNmsp = new object[1]; serviceCredSSPXMLNmsp[0] = wSManHelper.Service_CredSSP_XMLNmsp; string str1 = string.Format(CultureInfo.InvariantCulture, "<cfg:Auth xmlns:cfg=\"{0}\"><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>", serviceCredSSPXMLNmsp); wSManSession.Put(wSManHelper.Service_CredSSP_Uri, str1, 0); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, null); } if (wSManSession != null) { this.Dispose(wSManSession); } } return; } else { return; } }
private void DisableClientSideSettings() { WSManHelper wSManHelper = new WSManHelper(this); IWSManSession wSManSession = base.CreateWSManSession(); if (wSManSession != null) { try { try { string str = wSManSession.Get(wSManHelper.CredSSP_RUri, 0); XmlDocument xmlDocument = new XmlDocument(); xmlDocument.LoadXml(str); XmlNamespaceManager xmlNamespaceManagers = new XmlNamespaceManager(xmlDocument.NameTable); xmlNamespaceManagers.AddNamespace("cfg", wSManHelper.CredSSP_XMLNmsp); XmlNode xmlNodes = xmlDocument.SelectSingleNode(wSManHelper.CredSSP_SNode, xmlNamespaceManagers); if (xmlNodes == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, wSManHelper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); return; } else { string str1 = "<cfg:Auth xmlns:cfg=\"http://schemas.microsoft.com/wbem/wsman/1/config/client/auth\"><cfg:CredSSP>false</cfg:CredSSP></cfg:Auth>"; wSManSession.Put(wSManHelper.CredSSP_RUri, str1, 0); if (Thread.CurrentThread.GetApartmentState() != ApartmentState.STA) { ThreadStart threadStart = new ThreadStart(this.DeleteUserDelegateSettings); Thread thread = new Thread(threadStart); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } else { this.DeleteUserDelegateSettings(); } if (!wSManHelper.ValidateCreadSSPRegistryRetry(false, null, "wsman")) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("DisableCredSSPPolicyValidateError"), false, null); } } } catch (XPathException xPathException1) { XPathException xPathException = xPathException1; ErrorRecord errorRecord1 = new ErrorRecord(xPathException, "XpathException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord1); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, null); } if (wSManSession != null) { this.Dispose(wSManSession); } } return; } else { return; } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { //If not running elevated, then throw an "elevation required" error message. WSManHelper.ThrowIfNotAdministrator(); helper = new WSManHelper(this); String query = helper.GetResourceMsgFromResourcetext("QuickConfigContinueQuery"); String caption = helper.GetResourceMsgFromResourcetext("QuickConfigContinueCaption"); if (!force && !ShouldContinue(query, caption)) { return; } QuickConfigRemoting(true); QuickConfigRemoting(false); }//End BeginProcessing()
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if (this.connectionuri != null) { try { string[] strArrays = new string[1]; object[] objArray = new object[4]; objArray[0] = ":"; objArray[1] = this.port; objArray[2] = "/"; objArray[3] = this.applicationname; strArrays[0] = string.Concat(objArray); string[] strArrays1 = this.connectionuri.OriginalString.Split(strArrays, StringSplitOptions.None); string[] strArrays2 = new string[1]; strArrays2[0] = "//"; string[] strArrays3 = strArrays1[0].Split(strArrays2, StringSplitOptions.None); this.computername = strArrays3[1].Trim(); } catch (IndexOutOfRangeException indexOutOfRangeException) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, this.connectionuri); } } string str = this.computername; if (str == null) { str = "localhost"; } object[] name = new object[4]; name[0] = base.SessionState.Drive.Current.Name; name[1] = ":"; name[2] = (char)92; name[3] = str; if (base.SessionState.Path.CurrentProviderLocation("WSMan").Path.StartsWith(string.Concat(name), StringComparison.CurrentCultureIgnoreCase)) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("ConnectFailure"), false, this.computername); } wSManHelper.CreateWsManConnection(base.ParameterSetName, this.connectionuri, this.port, this.computername, this.applicationname, this.usessl.IsPresent, this.Authentication, this.sessionoption, this.Credential, this.CertificateThumbprint); }
/// <summary> /// ProcessRecord method. /// </summary> protected override void ProcessRecord() { IWSManEx m_wsmanObject = (IWSManEx)new WSManClass(); helper = new WSManHelper(this); helper.WSManOp = "set"; IWSManSession m_session = null; if (dialect != null) { if (dialect.ToString().Equals(helper.ALIAS_WQL, StringComparison.CurrentCultureIgnoreCase)) dialect = new Uri(helper.URI_WQL_DIALECT); if (dialect.ToString().Equals(helper.ALIAS_SELECTOR, StringComparison.CurrentCultureIgnoreCase)) dialect = new Uri(helper.URI_SELECTOR_DIALECT); if (dialect.ToString().Equals(helper.ALIAS_ASSOCIATION, StringComparison.CurrentCultureIgnoreCase)) dialect = new Uri(helper.URI_ASSOCIATION_DIALECT); } try { string connectionStr = String.Empty; connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname); if (connectionuri != null) { try { //in the format http(s)://server[:port/applicationname] string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, fragment, dialect, m_wsmanObject, resourceuri); m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent); string rootNode = helper.GetRootNodeName(helper.WSManOp, m_resource.ResourceUri, null); string input = helper.ProcessInput(m_wsmanObject, filepath, helper.WSManOp, rootNode, valueset, m_resource, m_session); XmlDocument xmldoc = new XmlDocument(); try { xmldoc.LoadXml(m_session.Put(m_resource, input, 0)); } catch(XmlException ex) { helper.AssertError(ex.Message, false, computername); } if (!string.IsNullOrEmpty(fragment)) { if (xmldoc.DocumentElement.ChildNodes.Count > 0) { foreach (XmlNode node in xmldoc.DocumentElement.ChildNodes) { if (node.Name.Equals(fragment, StringComparison.CurrentCultureIgnoreCase)) WriteObject(node.Name + " = " + node.InnerText); } } } else WriteObject(xmldoc.DocumentElement); } finally { if (!String.IsNullOrEmpty(m_wsmanObject.Error)) { helper.AssertError(m_wsmanObject.Error, true, resourceuri); } if (!String.IsNullOrEmpty(m_session.Error)) { helper.AssertError(m_session.Error, true, resourceuri); } if (m_session != null) Dispose(m_session); } }//End ProcessRecord()
/// <summary> /// </summary> /// <exception cref="InvalidOperationException"> /// </exception> private void EnableClientSideSettings() { string query = helper.GetResourceMsgFromResourcetext("CredSSPContinueQuery"); string caption = helper.GetResourceMsgFromResourcetext("CredSSPContinueCaption"); if (!force && !ShouldContinue(query, caption)) { return; } IWSManSession m_SessionObj = CreateWSManSession(); if (m_SessionObj == null) { return; } try { // get the credssp node to check if wsman is configured on this machine string result = m_SessionObj.Get(helper.CredSSP_RUri, 0); XmlNode node = helper.GetXmlNode(result, helper.CredSSP_SNode, helper.CredSSP_XMLNmsp); if (node == null) { InvalidOperationException ex = new InvalidOperationException(); ErrorRecord er = new ErrorRecord(ex, helper.GetResourceMsgFromResourcetext("WinrmNotConfigured"), ErrorCategory.InvalidOperation, null); WriteError(er); return; } const string newxmlcontent = @"<cfg:Auth xmlns:cfg=""http://schemas.microsoft.com/wbem/wsman/1/config/client/auth""><cfg:CredSSP>true</cfg:CredSSP></cfg:Auth>"; try { XmlDocument xmldoc = new XmlDocument(); // push the xml string with credssp enabled xmldoc.LoadXml(m_SessionObj.Put(helper.CredSSP_RUri, newxmlcontent, 0)); // set the Registry using GroupPolicyObject if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA) { this.UpdateCurrentUserRegistrySettings(); } else { ThreadStart start = new ThreadStart(this.UpdateCurrentUserRegistrySettings); Thread thread = new Thread(start); thread.SetApartmentState(ApartmentState.STA); thread.Start(); thread.Join(); } if (helper.ValidateCreadSSPRegistryRetry(true, delegatecomputer, applicationname)) { WriteObject(xmldoc.FirstChild); } else { helper.AssertError(helper.GetResourceMsgFromResourcetext("EnableCredSSPPolicyValidateError"), false, delegatecomputer); } } catch (COMException) { helper.AssertError(m_SessionObj.Error, true, delegatecomputer); } } finally { if (!string.IsNullOrEmpty(m_SessionObj.Error)) { helper.AssertError(m_SessionObj.Error, true, delegatecomputer); } if (m_SessionObj != null) { Dispose(m_SessionObj); } } }
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (computername == null) { computername = "localhost"; } if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(WSManStringLiterals.rootpath + ":" + WSManStringLiterals.DefaultPathSeparator + computername, StringComparison.CurrentCultureIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("DisconnectFailure"), false, computername); } if (computername.Equals("localhost", StringComparison.CurrentCultureIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("LocalHost"), false, computername); } object _ws = helper.RemoveFromDictionary(computername); if (_ws != null) { Dispose(_ws); } else { helper.AssertError(helper.GetResourceMsgFromResourcetext("InvalidComputerName"), false, computername); } }//End BeginProcessing()
protected override void BeginProcessing() { WSManHelper wSManHelper = new WSManHelper(this); if ((this.proxyauthentication.Equals(ProxyAuthentication.Basic) || this.proxyauthentication.Equals(ProxyAuthentication.Digest)) && this._proxycredential == null) { InvalidOperationException invalidOperationException = new InvalidOperationException(wSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionCred")); ErrorRecord errorRecord = new ErrorRecord(invalidOperationException, "InvalidOperationException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord); return; } else { if (this._proxycredential == null || this.proxyauthentication != 0) { SessionOption sessionOption = new SessionOption(); sessionOption.SPNPort = this.spnport; sessionOption.UseUtf16 = this.useutf16; sessionOption.SkipCNCheck = this.skipcncheck; sessionOption.SkipCACheck = this.skipcacheck; sessionOption.OperationTimeout = this.operationtimeout; sessionOption.SkipRevocationCheck = this.skiprevocationcheck; sessionOption.ProxyAccessType = this._proxyacesstype; sessionOption.ProxyAuthentication = this.proxyauthentication; if (this.noencryption) { sessionOption.UseEncryption = false; } if (this._proxycredential != null) { NetworkCredential networkCredential = this._proxycredential.GetNetworkCredential(); sessionOption.ProxyCredential = networkCredential; } base.WriteObject(sessionOption); return; } else { InvalidOperationException invalidOperationException1 = new InvalidOperationException(wSManHelper.GetResourceMsgFromResourcetext("NewWSManSessionOptionAuth")); ErrorRecord errorRecord1 = new ErrorRecord(invalidOperationException1, "InvalidOperationException", ErrorCategory.InvalidOperation, null); base.WriteError(errorRecord1); return; } } }
/// <summary> /// ProcessRecord method. /// </summary> protected override void ProcessRecord() { WSManHelper helper = new WSManHelper(this); IWSManEx m_wsmanObject = (IWSManEx)new WSManClass(); helper.WSManOp = "remove"; IWSManSession m_session = null; try { string connectionStr = String.Empty; connectionStr = helper.CreateConnectionString(connectionuri, port, computername, applicationname); if (connectionuri != null) { try { //in the format http(s)://server[:port/applicationname] string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } IWSManResourceLocator m_resource = helper.InitializeResourceLocator(optionset, selectorset, null, null, m_wsmanObject, resourceuri); m_session = helper.CreateSessionObject(m_wsmanObject, Authentication, sessionoption, Credential, connectionStr, CertificateThumbprint, usessl.IsPresent); string ResourceURI = helper.GetURIWithFilter(resourceuri.ToString(), null, selectorset, helper.WSManOp); try { ((IWSManSession)m_session).Delete(ResourceURI, 0); } catch (Exception ex) { helper.AssertError(ex.Message, false, computername); } } finally { if (!String.IsNullOrEmpty(m_session.Error)) { helper.AssertError(m_session.Error, true, resourceuri); } if (!String.IsNullOrEmpty(m_wsmanObject.Error)) { helper.AssertError(m_wsmanObject.Error, true, resourceuri); } if (m_session != null) Dispose(m_session); } }//End ProcessRecord()
/// <summary> /// BeginProcessing method. /// </summary> protected override void BeginProcessing() { WSManHelper helper = new WSManHelper(this); if (connectionuri != null) { try { //always in the format http://server:port/applicationname string[] constrsplit = connectionuri.OriginalString.Split(new string[] { ":" + port + "/" + applicationname }, StringSplitOptions.None); string[] constrsplit1 = constrsplit[0].Split(new string[] { "//" }, StringSplitOptions.None); computername = constrsplit1[1].Trim(); } catch (IndexOutOfRangeException) { helper.AssertError(helper.GetResourceMsgFromResourcetext("NotProperURI"), false, connectionuri); } } string crtComputerName = computername; if (crtComputerName == null) { crtComputerName = "localhost"; } if (this.SessionState.Path.CurrentProviderLocation(WSManStringLiterals.rootpath).Path.StartsWith(this.SessionState.Drive.Current.Name + ":" + WSManStringLiterals.DefaultPathSeparator + crtComputerName, StringComparison.CurrentCultureIgnoreCase)) { helper.AssertError(helper.GetResourceMsgFromResourcetext("ConnectFailure"), false, computername); } helper.CreateWsManConnection(ParameterSetName, connectionuri, port, computername, applicationname, usessl.IsPresent, Authentication, sessionoption, Credential, CertificateThumbprint); }//End BeginProcessing()
protected override void ProcessRecord() { WSManHelper wSManHelper = new WSManHelper(this); IWSManEx wSManClass = (IWSManEx)(new WSManClass()); wSManHelper.WSManOp = "remove"; IWSManSession wSManSession = null; try { string str = wSManHelper.CreateConnectionString(this.connectionuri, this.port, this.computername, this.applicationname); if (this.connectionuri != null) { try { string[] strArrays = new string[1]; object[] objArray = new object[4]; objArray[0] = ":"; objArray[1] = this.port; objArray[2] = "/"; objArray[3] = this.applicationname; strArrays[0] = string.Concat(objArray); string[] strArrays1 = this.connectionuri.OriginalString.Split(strArrays, StringSplitOptions.None); string[] strArrays2 = new string[1]; strArrays2[0] = "//"; string[] strArrays3 = strArrays1[0].Split(strArrays2, StringSplitOptions.None); this.computername = strArrays3[1].Trim(); } catch (IndexOutOfRangeException indexOutOfRangeException) { wSManHelper.AssertError(wSManHelper.GetResourceMsgFromResourcetext("NotProperURI"), false, this.connectionuri); } } wSManHelper.InitializeResourceLocator(this.optionset, this.selectorset, null, null, wSManClass, this.resourceuri); wSManSession = wSManHelper.CreateSessionObject(wSManClass, this.Authentication, this.sessionoption, this.Credential, str, this.CertificateThumbprint, this.usessl.IsPresent); string uRIWithFilter = wSManHelper.GetURIWithFilter(this.resourceuri.ToString(), null, this.selectorset, wSManHelper.WSManOp); try { wSManSession.Delete(uRIWithFilter, 0); } catch (Exception exception1) { Exception exception = exception1; wSManHelper.AssertError(exception.Message, false, this.computername); } } finally { if (!string.IsNullOrEmpty(wSManSession.Error)) { wSManHelper.AssertError(wSManSession.Error, true, this.resourceuri); } if (!string.IsNullOrEmpty(wSManClass.Error)) { wSManHelper.AssertError(wSManClass.Error, true, this.resourceuri); } if (wSManSession != null) { this.Dispose(wSManSession); } } }