Пример #1
0
        /// <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()
Пример #2
0
		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);
				}
			}
		}
Пример #3
0
        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);
                }
            }
        }