Avatar of Leon Taljaard
Leon TaljaardFlag for South Africa asked on

Use Powershell to call web services

Hi Guys,

I have to web services that i need to call within PowerShell, my problem is that i need to call the first one to authenticate and keep the session open and then i can call or open my second service to get the xml response.

So the first one kind of looks like this

Context.PNG
Then after I have entered the required in the first and clicked "Invoke" and while keeping the same web page/session open i can then open the second asmx/wsdl as below

Customer.PNG
Then after i type the required parameters in an click "Invoke" i get my response payload which is what i need, now the problem is that i need to do this within powershell so that i can automate the authentication and keep the session open and so that i can do my second request and get the response xml payload so that i can check the result.

Please can someone help me accomplish this with Powershell or perhaps C# ?

Thanks

Leon
WCFWindows Server 2008

Avatar of undefined
Last Comment
Qlemo

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Qlemo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Leon Taljaard

Hi There,

the rest seems to be working but i am getting an error on the first URL, it is giving me this when trying to click the "Invoke" button

You cannot call a method on a null-valued expression.
At line:18 char:1
+ $ie.Document.getElementByID('Invoke').Click()

Open in new window


Thanks
ASKER
Leon Taljaard

Hi I have even tried this

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $true

# First web site
$username = 'username'
$Password ='password'
$DSN = 'dsn'
$ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/context.asmx?op=Login')
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }

$Usernamefield = $ie.Document.getElementByID('username')
$Usernamefield.value = $username

$PasswordField = $ie.Document.getElementByID('password')
$PasswordField.value = $Password

$DSNField = $ie.Document.getElementByID('dsn')
$DSNField.value = $DSN

$Link = $ie.Document.getElementsByTagName("submit") | where-object {$_.classname -eq "button"}
$Link.click()



# Second web site
# similar as above

$resultXML = $ie.Document.InnerHTML

Open in new window


But i get this error

You cannot call a method on a null-valued expression.
At line:26 char:1
+ $Link.click()
+ ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

Open in new window


Here is the html data of the first page

<html>

    <head><link rel="alternate" type="text/xml" href="/ibsv54/_Ws/context.asmx?disco" />

    <style type="text/css">
    
		BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
		#content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }
		A:link { color: #336699; font-weight: bold; text-decoration: underline; }
		A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }
		A:active { color: #336699; font-weight: bold; text-decoration: underline; }
		A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }
		P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; }
		pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }
		td { color: #000000; font-family: Verdana; font-size: .7em; }
		h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }
		h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }
		ul { margin-top: 10px; margin-left: 20px; }
		ol { margin-top: 10px; margin-left: 20px; }
		li { margin-top: 10px; color: #000000; }
		font.value { color: darkblue; font: bold; }
		font.key { color: darkgreen; font: bold; }
		font.error { color: darkred; font: bold; }
		.heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }
		.button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }
		.frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }
		.frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }
		.frmInput { font-family: Verdana; font-size: 1em; }
		.intro { margin-left: -15px; }
           
    </style>

    <title>
	Context Web Service
</title></head>

  <body>

    <div id="content">

      <p class="heading1">Context</p><br>

      

      

      <span>
          <p class="intro">Click <a href="context.asmx">here</a> for a complete list of operations.</p>
          <h2>Login</h2>
          <p class="intro"></p>

          <h3>Test</h3>
          
          To test the operation using the HTTP POST protocol, click the 'Invoke' button.



                      <form target="_blank" action='http://23rnb-w4iis2/ibsv54/_Ws/context.asmx/Login' method="POST">                      
                        
                          <table cellspacing="0" cellpadding="4" frame="box" bordercolor="#dcdcdc" rules="none" style="border-collapse: collapse;">
                          <tr>
	<td class="frmHeader" background="#dcdcdc" style="border-right: 2px solid white;">Parameter</td>
	<td class="frmHeader" background="#dcdcdc">Value</td>
</tr>

                        
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">Username:</td>
                            <td><input class="frmInput" type="text" size="50" name="Username"></td>
                          </tr>
                        
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">Password:</td>
                            <td><input class="frmInput" type="text" size="50" name="Password"></td>
                          </tr>
                        
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">DSN:</td>
                            <td><input class="frmInput" type="text" size="50" name="DSN"></td>
                          </tr>
                        
                        <tr>
                          <td></td>
                          <td align="right"> <input type="submit" value="Invoke" class="button"></td>
                        </tr>
                        </table>
                      

                    </form>
                  <span>
              <h3>SOAP 1.1</h3>
              <p>The following is a sample SOAP 1.1 request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/context.asmx HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>
SOAPAction: "http://tempuri.org/Login"

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;Login xmlns="http://tempuri.org/"&gt;
      &lt;Username&gt;<font class=value>string</font>&lt;/Username&gt;
      &lt;Password&gt;<font class=value>string</font>&lt;/Password&gt;
      &lt;DSN&gt;<font class=value>string</font>&lt;/DSN&gt;
    &lt;/Login&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;LoginResponse xmlns="http://tempuri.org/"&gt;
      &lt;LoginResult&gt;<font class=value>string</font>&lt;/LoginResult&gt;
    &lt;/LoginResponse&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
          </span>

          <span>
              <h3>SOAP 1.2</h3>
              <p>The following is a sample SOAP 1.2 request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/context.asmx HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;soap12:Body&gt;
    &lt;Login xmlns="http://tempuri.org/"&gt;
      &lt;Username&gt;<font class=value>string</font>&lt;/Username&gt;
      &lt;Password&gt;<font class=value>string</font>&lt;/Password&gt;
      &lt;DSN&gt;<font class=value>string</font>&lt;/DSN&gt;
    &lt;/Login&gt;
  &lt;/soap12:Body&gt;
&lt;/soap12:Envelope&gt;</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;soap12:Body&gt;
    &lt;LoginResponse xmlns="http://tempuri.org/"&gt;
      &lt;LoginResult&gt;<font class=value>string</font>&lt;/LoginResult&gt;
    &lt;/LoginResponse&gt;
  &lt;/soap12:Body&gt;
&lt;/soap12:Envelope&gt;</pre>
          </span>

          <span>
              <h3>HTTP GET</h3>
              <p>The following is a sample HTTP GET request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>GET /ibsv54/_Ws/context.asmx/Login?<font class=key>Username</font>=<font class=value>string</font>&amp;<font class=key>Password</font>=<font class=value>string</font>&amp;<font class=key>DSN</font>=<font class=value>string</font> HTTP/1.1
Host: 23rnb-w4iis2
</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://tempuri.org/"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

          <span>
              <h3>HTTP POST</h3>
              <p>The following is a sample HTTP POST request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/context.asmx/Login HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: application/x-www-form-urlencoded
Content-Length: <font class=value>length</font>

<font class=key>Username</font>=<font class=value>string</font>&amp;<font class=key>Password</font>=<font class=value>string</font>&amp;<font class=key>DSN</font>=<font class=value>string</font></pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://tempuri.org/"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

      </span>
      

    
    
      

      

    
  </body>
</html>

Open in new window


Here is the code for the second page

<html>

    <head><link rel="alternate" type="text/xml" href="/ibsv54/_Ws/customer.asmx?disco" />

    <style type="text/css">
    
		BODY { color: #000000; background-color: white; font-family: Verdana; margin-left: 0px; margin-top: 0px; }
		#content { margin-left: 30px; font-size: .70em; padding-bottom: 2em; }
		A:link { color: #336699; font-weight: bold; text-decoration: underline; }
		A:visited { color: #6699cc; font-weight: bold; text-decoration: underline; }
		A:active { color: #336699; font-weight: bold; text-decoration: underline; }
		A:hover { color: cc3300; font-weight: bold; text-decoration: underline; }
		P { color: #000000; margin-top: 0px; margin-bottom: 12px; font-family: Verdana; }
		pre { background-color: #e5e5cc; padding: 5px; font-family: Courier New; font-size: x-small; margin-top: -5px; border: 1px #f0f0e0 solid; }
		td { color: #000000; font-family: Verdana; font-size: .7em; }
		h2 { font-size: 1.5em; font-weight: bold; margin-top: 25px; margin-bottom: 10px; border-top: 1px solid #003366; margin-left: -15px; color: #003366; }
		h3 { font-size: 1.1em; color: #000000; margin-left: -15px; margin-top: 10px; margin-bottom: 10px; }
		ul { margin-top: 10px; margin-left: 20px; }
		ol { margin-top: 10px; margin-left: 20px; }
		li { margin-top: 10px; color: #000000; }
		font.value { color: darkblue; font: bold; }
		font.key { color: darkgreen; font: bold; }
		font.error { color: darkred; font: bold; }
		.heading1 { color: #ffffff; font-family: Tahoma; font-size: 26px; font-weight: normal; background-color: #003366; margin-top: 0px; margin-bottom: 0px; margin-left: -30px; padding-top: 10px; padding-bottom: 3px; padding-left: 15px; width: 105%; }
		.button { background-color: #dcdcdc; font-family: Verdana; font-size: 1em; border-top: #cccccc 1px solid; border-bottom: #666666 1px solid; border-left: #cccccc 1px solid; border-right: #666666 1px solid; }
		.frmheader { color: #000000; background: #dcdcdc; font-family: Verdana; font-size: .7em; font-weight: normal; border-bottom: 1px solid #dcdcdc; padding-top: 2px; padding-bottom: 2px; }
		.frmtext { font-family: Verdana; font-size: .7em; margin-top: 8px; margin-bottom: 0px; margin-left: 32px; }
		.frmInput { font-family: Verdana; font-size: 1em; }
		.intro { margin-left: -15px; }
           
    </style>

    <title>
	Customer Web Service
</title></head>

  <body>

    <div id="content">

      <p class="heading1">Customer</p><br>

      

      

      <span>
          <p class="intro">Click <a href="customer.asmx">here</a> for a complete list of operations.</p>
          <h2>LoadOverview</h2>
          <p class="intro"></p>

          <h3>Test</h3>
          
          To test the operation using the HTTP POST protocol, click the 'Invoke' button.



                      <form target="_blank" action='http://23rnb-w4iis2/ibsv54/_Ws/customer.asmx/LoadOverview' method="POST">                      
                        
                          <table cellspacing="0" cellpadding="4" frame="box" bordercolor="#dcdcdc" rules="none" style="border-collapse: collapse;">
                          <tr>
	<td class="frmHeader" background="#dcdcdc" style="border-right: 2px solid white;">Parameter</td>
	<td class="frmHeader" background="#dcdcdc">Value</td>
</tr>

                        
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">Token:</td>
                            <td><input class="frmInput" type="text" size="50" name="Token"></td>
                          </tr>
                        
                          <tr>
                            <td class="frmText" style="color: #000000; font-weight: normal;">CustomerId:</td>
                            <td><input class="frmInput" type="text" size="50" name="CustomerId"></td>
                          </tr>
                        
                        <tr>
                          <td></td>
                          <td align="right"> <input type="submit" value="Invoke" class="button"></td>
                        </tr>
                        </table>
                      

                    </form>
                  <span>
              <h3>SOAP 1.1</h3>
              <p>The following is a sample SOAP 1.1 request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/customer.asmx HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>
SOAPAction: "http://tempuri.org/LoadOverview"

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;LoadOverview xmlns="http://tempuri.org/"&gt;
      &lt;Token&gt;<font class=value>string</font>&lt;/Token&gt;
      &lt;CustomerId&gt;<font class=value>int</font>&lt;/CustomerId&gt;
    &lt;/LoadOverview&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"&gt;
  &lt;soap:Body&gt;
    &lt;LoadOverviewResponse xmlns="http://tempuri.org/"&gt;
      &lt;LoadOverviewResult&gt;<font class=value>string</font>&lt;/LoadOverviewResult&gt;
    &lt;/LoadOverviewResponse&gt;
  &lt;/soap:Body&gt;
&lt;/soap:Envelope&gt;</pre>
          </span>

          <span>
              <h3>SOAP 1.2</h3>
              <p>The following is a sample SOAP 1.2 request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/customer.asmx HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;soap12:Body&gt;
    &lt;LoadOverview xmlns="http://tempuri.org/"&gt;
      &lt;Token&gt;<font class=value>string</font>&lt;/Token&gt;
      &lt;CustomerId&gt;<font class=value>int</font>&lt;/CustomerId&gt;
    &lt;/LoadOverview&gt;
  &lt;/soap12:Body&gt;
&lt;/soap12:Envelope&gt;</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope"&gt;
  &lt;soap12:Body&gt;
    &lt;LoadOverviewResponse xmlns="http://tempuri.org/"&gt;
      &lt;LoadOverviewResult&gt;<font class=value>string</font>&lt;/LoadOverviewResult&gt;
    &lt;/LoadOverviewResponse&gt;
  &lt;/soap12:Body&gt;
&lt;/soap12:Envelope&gt;</pre>
          </span>

          <span>
              <h3>HTTP GET</h3>
              <p>The following is a sample HTTP GET request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>GET /ibsv54/_Ws/customer.asmx/LoadOverview?<font class=key>Token</font>=<font class=value>string</font>&amp;<font class=key>CustomerId</font>=<font class=value>string</font> HTTP/1.1
Host: 23rnb-w4iis2
</pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://tempuri.org/"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

          <span>
              <h3>HTTP POST</h3>
              <p>The following is a sample HTTP POST request and response.  The <font class=value>placeholders</font> shown need to be replaced with actual values.</p>

              <pre>POST /ibsv54/_Ws/customer.asmx/LoadOverview HTTP/1.1
Host: 23rnb-w4iis2
Content-Type: application/x-www-form-urlencoded
Content-Length: <font class=value>length</font>

<font class=key>Token</font>=<font class=value>string</font>&amp;<font class=key>CustomerId</font>=<font class=value>string</font></pre>

              <pre>HTTP/1.1 200 OK
Content-Type: text/xml; charset=utf-8
Content-Length: <font class=value>length</font>

&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;string xmlns="http://tempuri.org/"&gt;<font class=value>string</font>&lt;/string&gt;</pre>
          </span>

      </span>
      

    
    
      

      

    
  </body>
</html>

Open in new window


So it looks like i am just missing something on the click
ASKER
Leon Taljaard

Hi,

I got it working, my only question now is how do i get the second page result out in XML output into powershell and not opening the page and xml in IE ?

This is my final PowerShell script

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $true

# First web site
$username = 'username'
$Password ='password'
$DSN = 'dsn'
$ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/context.asmx?op=Login')
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }

$Usernamefield = $ie.Document.getElementByID('username')
$Usernamefield.value = $username

$PasswordField = $ie.Document.getElementByID('password')
$PasswordField.value = $Password

$DSNField = $ie.Document.getElementByID('dsn')
$DSNField.value = $DSN

$Link = $ie.Document.getElementsByTagName("input") | ? {$_.Type -eq 'submit'} | % {$_.Click()}




# Second web site
# similar as above

$Token = 'token'
$CustomerID ='number'
$ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/customer.asmx?op=LoadOverview')
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }

$Tokenfield = $ie.Document.getElementByID('Token')
$Tokenfield.value = $Token

$CustomerIDField = $ie.Document.getElementByID('CustomerID')
$CustomerIDField.value = $CustomerID

$Link = $ie.Document.getElementsByTagName("input") | ? {$_.Type -eq 'submit'} | % {$_.Click()}

$resultXML = $ie.Document.InnerHTML
$resultXML

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
ASKER
Leon Taljaard

Hi,

I think i forgot to mention that I need the output of the second page which is a XML output to be output into PowerShell because i need to consume the result.

Also what is happening is that when i click Invoke it opens a new TAB where the results are so when i try get the body it is displaying the body showing the examples on how to do a Get/SOAP and so on not the actual result. I also cannot have it open IE as this needs to be completely silent as all I am looking for is the result which i check with another system.
Qlemo

$resultXML should contain the XML code.

You do not need to use e.g.
$Tokenfield = $ie.Document.getElementByID('Token')
$Tokenfield.value = $Token

Open in new window

if you are not checking the var for a value. It is the same as
$ie.Document.getElementByID('Token').value = $Token

Open in new window

but doesn't require to store the object.
Qlemo

To hide IE, set $ie.visible = $false.

The other stuff I did not get. If you see it on screen in IE, you can check the result properties with F12. You need to drill down to the tags, IDs, or whatever to be able to specify the XML part.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Leon Taljaard

Ok, i have set it to $ie.visible = $false but IE still opens, but regardless of that this is what i am meaning.

when i run my script

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $false

# First web site
$username = 'za\btgaccount'
$Password ='BTG@ccount2'
$DSN = 'DTH'
$Page1 = $ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/context.asmx?op=Login')
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }

$Usernamefield = $ie.Document.getElementByID('username')
$Usernamefield.value = $username

$PasswordField = $ie.Document.getElementByID('password')
$PasswordField.value = $Password

$DSNField = $ie.Document.getElementByID('dsn')
$DSNField.value = $DSN

$Link = $ie.Document.getElementsByTagName("input") | ? {$_.Type -eq 'submit'} | % {$_.Click()}


# Second web site
# similar as above


$Token = 'DTH'
$CustomerID ='36526867'
$ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/customer.asmx?op=LoadOverview')
while ($ie.busy)                               { Start-Sleep -m 300 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 300 }

$ie.Document.getElementByID('Token').value = $Token

$ie.Document.getElementByID('CustomerID').value = $CustomerID

$Link = $ie.Document.getElementsByTagName("input") | ? {$_.Type -eq 'submit'} | % {$_.Click()}

$resultXML = $ie.Document.InnerHTML

Open in new window


It then opens 3 IE tabs, one tab from the result of the first login and then the second page where it asks for Token and CustomerID and then a 3rd tab where the actual xml output is, so the actual data i want to see within Powershell.

This is the result, but i just cant get that in the powershell output

XML.PNG
Qlemo

Try if inserting lines 13-14 after line 25 and again after line 42 prevents new tabs to open.
ASKER
Leon Taljaard

Hi,

Nope, it just keeps opening the new tabs, so my output is on another TAB so when i call the $ie.Document it is outputting the first page where the examples are shown of what to type in, like the SOAP 1.1 and HTTP GET examples.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
ASKER
Leon Taljaard

Is there no way i can perhaps use New-WebServiceProxy or Invoke-WebRequest to accomplish this with opening 2 pages where the first one is just required to open a session for the first ?
ASKER
Leon Taljaard

Or even C# ?
Qlemo

The issue is not with the scripting or progamming language, but with the Automation objects for IE. The WebRequest could be used if it didn't need any interaction. The best you can do is to stop from using the second page to get data, but use the SOAP or HTTP GET methods directly. Again: "If available, just building the corresponding URL is a better idea (instead of filling out the second form)."
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Leon Taljaard

Ok not too sure how i would accomplish that because i need the data from the second url, not sure how i would use a SOAP or Get within Powershell to get the xml payload result after authenticating with the first page.

I am no too familiar with trying to get the info with GET and SOAP.
ASKER
Leon Taljaard

This is the first page

FistPage.PNG
This is the second page

SecondPage.PNG
Now obviously  I need to call the first page to create a session and then call the second page and get the xml result output into a variable i can use.
Qlemo

If you can build an URL for the last step, it is most easy. Otherwise I don't have a clue either without being able to try myself.
Your help has saved me hundreds of hours of internet surfing.
fblack61
Qlemo

Getting the posted images has some issue at the moment. Can you post the content as text in a "Code" block, please?
ASKER
Leon Taljaard

Hi think i got it !! :)

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $false

# First web site
$Page1 = $ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/context.asmx/Login?Username=value&Password=value&DSN=value')
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }

# Second web site
# similar as above


$Token = 'value'
$CustomerID ='value'
$ie.Navigate('http://23rnb-w4iis2/ibsv54/_Ws/customer.asmx/LoadOverview?Token=value&CustomerId=value')
while ($ie.busy)                               { Start-Sleep -m 300 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 300 }


$resultXML = $ie.Document.body.outertext
$resultXML

Open in new window


I filled in the "value" with the required parameters and i now get the xml out, my only problem now is to get just the /Customer/id out of the returned XML, so not sure whats the best way to get it out in the last part of my script, should i use $ie.Document.body.outertext or innerHTML or what ?
Qlemo

If the content is indeed XML, you can convert it to a [XML] object, and access it by path. As an example:
[xml] $xml = '<Customer><ID>4711</ID><Comment>Nothing to say here</Comment></Customer>'
$xml.Customer.ID

Open in new window

All you need is to locate the pure XML code part of the HTML response.
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Leon Taljaard

This is what i get when i use $ie.Doument.Body.outertext

<?xml version="1.0" encoding="utf-8" ?> 
  <string xmlns="http://tempuri.org/"><xml><hasaccounts>true</hasaccounts><hasproducts>true</hasproducts><Customer><id>VALUE</id><birthdate

Open in new window


so when i do a xml query to only get the customer number i am using the output and then //Customer/id as the XPath Query but i am not getting a result
SOLUTION
Qlemo

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Leon Taljaard

Hi Qlemo,

I must say thank you for all this back and forth, I really appreciate it.

I am still not getting any result

should i put your above script into my main script like this or differently ?

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $false

# First web site #

$Username = 'Value'
$Password = 'Value'
$DSN = 'Value'

$ie.Navigate("http://23rnb-w4iis2/ibsv54/_Ws/context.asmx/Login?Username=$Username&Password=$Password&DSN=$DSN")
while ($ie.busy)                               { Start-Sleep -m 100 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 100 }


# Second web site #

$Token = 'Value'
$CustomerID ='Value'
$ie.Navigate("http://23rnb-w4iis2/ibsv54/_Ws/customer.asmx/LoadOverview?Token=$Token&CustomerId=$CustomerID")
while ($ie.busy)                               { Start-Sleep -m 300 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 300 }


##$resultXML = $ie.Document.body.innertext
#$resultXML

([xml] $($ie.Doument.Body.innertext -match '(\<xml\>.*\</xml\>)' | out-null; $matches[1])).Content.ID

Open in new window


I get the following error when i run it like that
Cannot index into a null array.
At line:31 char:78
+ ([xml] $($ie.Doument.Body.innertext -match '(\<xml\>.*\</xml\>)' | out-null; $ma ...
+                                                                              ~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Open in new window


I am so close :)
ASKER
Leon Taljaard

If there is anything that I might be able to provide as more info that might help please let me know
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
Qlemo

Post the complete result of $ie.Doument.Body.outertext as text, and I can try.
ASKER
Leon Taljaard

Thank you Qlemo

<?xml version="1.0" encoding="utf-8" ?> 
  <string xmlns="http://tempuri.org/"><xml><hasaccounts>true</hasaccounts><hasproducts>true</hasproducts><Customer><id>36526867</id><birthdate /><customertype>N</custom
ertype><cutype>SUD</cutype><exemptioncode /><exemptionfrom /><exemptionserialno /><existingcustomer>0</existingcustomer><fiscalcode /><fiscalno /><language>English</lan
guage><magazines>1</magazines><referenceno /><rsncreate>(None)</rsncreate><rsnmgmexisting>(None)</rsnmgmexisting><rsnmgmnew>(None)</rsnmgmnew><rsnmodified>(None)</rsnmo
dified><rsnstatuschange>(None)</rsnstatuschange><rsntypechange>(None)</rsntypechange><scheduleeventno>0</scheduleeventno><status>Active Customer</status><statuscode>A</
statuscode><referencetype>(None)</referencetype><segmentation /><letters /><correspondence>N</correspondence><smsreminders>S</smsreminders><dsdmessages>S</dsdmessages><
rdcheque>-1</rdcheque><crdate>0</crdate><marketresearch>0</marketresearch><marketresearchcontact>0</marketresearchcontact><thirdpartylist>0</thirdpartylist><acceptedter
ms>0</acceptedterms><countryoforigin /><passportexpirydate>11/29/2007 11:30:31 AM</passportexpirydate><companytype /><vatregno /><autoreconnect>False</autoreconnect><im
id /><dccpremiumsintermediary /><Hash>5A-F8-00-78-BD-FF-50-6B</Hash></Customer><Address><id>677812</id><eventno>100</eventno><customerid>36526867</customerid><accountid
>0</accountid><bigcity>BATH</bigcity><careof /><country>EQUATORIAL GUINEA</country><custproduct>0</custproduct><directions /><email /><extra /><extra1 /><extra2 /><extr
a3 /><extra4 /><extra5 /><fax1>222292250</fax1><fax2 /><firstname>STRONG</firstname><geocode>True</geocode><housenoalpha /><housenonum>0</housenonum><phonehome /><phone
work>240090664</phonework><postcode>31000</postcode><province>(None)</province><rsnmodified>(None)</rsnmodified><smallcity>BATH</smallcity><street>CERCA BANTU HOTEL</st
reet><streetdivision /><surname>DSIV</surname><title>Comp</title><validaddressid>0</validaddressid><rsnpsmodified /><addresstype>Default</addresstype><Hash>1A-BD-9D-56-
AF-83-EA-76</Hash></Address><Account><id>40362150</id><status>Open</status><redirectcustomerno>0</redirectcustomerno><acctypecode>D</acctypecode><acctype>Demo</acctype>
<mop>CASH-Cash payment</mop><invoiceperiod>1</invoiceperiod><marketsegment_name /><nid>14 Nov 2015</nid><amountoverdue>0</amountoverdue><totalamountsnotyet>0</totalamou
ntsnotyet><totalbalance>0</totalbalance><lastinvoiced>0</lastinvoiced><fistvalue /><accountcount>1</accountcount></Account><BusinessCollection type="multichoice.ibs.mol
.Product" assembly="multichoice.ibs.mol"><Product><accountno>40362150</accountno><contractenddate>24 Jun 2012</contractenddate><contractno /><contractperiod>1</contract
period><customerno>36526867</customerno><dealer>0</dealer><dealername /><dec_sclinked>False</dec_sclinked><dec_scmodel>W7PREM1-PREMIUM W7PREM1</dec_scmodel><dec_scno>10
13417424</dec_scno><dec_scstatus>(None)</dec_scstatus><financeoption>Subscription</financeoption><id>1818509</id><is_i3>False</is_i3><isactive>True</isactive><isdirty>F
alse</isdirty><linkeddecscno>1013417424</linkeddecscno><marketsegment>34459527</marketsegment><marketsegmentname>EQU</marketsegmentname><newnid /><nocommreason>(None)</
nocommreason><productno>542</productno><product_renamed>CHINAW7-DStv Great Wall Addon</product_renamed><pslink>865628</pslink><reauthorize>False</reauthorize><rsnmodifi
ed>(None)</rsnmodified><rsnfinanceoptionmodified>(None)</rsnfinanceoptionmodified><rsnpsrelink>(None)</rsnpsrelink><rsnreauthorize>(None)</rsnreauthorize><rsnspecialcsi
>(None)</rsnspecialcsi><rsnupdowngrade>(None)</rsnupdowngrade><scheduleeventno>0</scheduleeventno><setnid>False</setnid><specialcsi>False</specialcsi><contractstart>25 
May 2012</contractstart><status>Active</status><warranty /><productuserkey>CHINAW7</productuserkey><description>DStv Great Wall Addon</description><prdecscyn>0</prdecsc
yn><smartcardyn>0</smartcardyn><noofunits>0</noofunits><producttype>D</producttype><lastordernumber>476413</lastordernumber><rsncaredisc /><price>0</price><amortisation
quote>0</amortisationquote><deposit>0</deposit><instalment>0</instalment><isprimaryproduct>False</isprimaryproduct><canCancel>True</canCancel><canDisconnect>True</canDi
sconnect><canReconnect>True</canReconnect><discountProductprice>0</discountProductprice><discountProductuserkey /><isDiscount>0</isDiscount><Hash>5F-BF-35-A8-4B-65-01-7
B</Hash></Product><Product><accountno>40362150</accountno><contractenddate>14 Jul 2011</contractenddate><contractno /><contractperiod>1</contractperiod><customerno>3652
6867</customerno><dealer>36494076</dealer><dealername>3649407</dealername><dec_sclinked>True</dec_sclinked><dec_scmodel>DSD1132-DSD1132</dec_scmodel><dec_scno>V10537085
1</dec_scno><dec_scstatus>AT CUSTOMER</dec_scstatus><financeoption>Sold</financeoption><id>1236434</id><is_i3>False</is_i3><isactive>True</isactive><isdirty>False</isdi
rty><linkeddecscno>1013417424</linkeddecscno><marketsegment>34459527</marketsegment><marketsegmentname>EQU</marketsegmentname><newnid /><nocommreason>(None)</nocommreas
on><productno>538</productno><product_renamed>DSD1132-DSD1132</product_renamed><pslink>865628</pslink><reauthorize>False</reauthorize><rsnmodified>(None)</rsnmodified><
rsnfinanceoptionmodified>(None)</rsnfinanceoptionmodified><rsnpsrelink>(None)</rsnpsrelink><rsnreauthorize>(None)</rsnreauthorize><rsnspecialcsi>(None)</rsnspecialcsi><
rsnupdowngrade>(None)</rsnupdowngrade><scheduleeventno>0</scheduleeventno><setnid>False</setnid><specialcsi>False</specialcsi><contractstart>14 Jun 2011</contractstart>
<status>At Customer</status><warranty>26 Jan 2015</warranty><productuserkey>DSD1132</productuserkey><description>DSD1132</description><prdecscyn>1</prdecscyn><smartcard
yn>0</smartcardyn><noofunits>0</noofunits><producttype>I</producttype><lastordernumber>476413</lastordernumber><rsncaredisc /><price>0</price><amortisationquote>0</amor
tisationquote><deposit>0</deposit><instalment>0</instalment><isprimaryproduct>False</isprimaryproduct><canCancel>False</canCancel><canDisconnect>False</canDisconnect><c
anReconnect>True</canReconnect><discountProductprice>0</discountProductprice><discountProductuserkey /><isDiscount>0</isDiscount><Hash>C3-52-FD-72-74-A0-EF-10</Hash></P
roduct><Product><accountno>40362150</accountno><contractenddate>14 Jul 2011</contractenddate><contractno /><contractperiod>1</contractperiod><customerno>36526867</custo
merno><dealer>36494076</dealer><dealername>3649407</dealername><dec_sclinked>False</dec_sclinked><dec_scmodel>W7PREM1-PREMIUM W7PREM1</dec_scmodel><dec_scno>1013417424<
/dec_scno><dec_scstatus>(None)</dec_scstatus><financeoption>Subscription</financeoption><id>1236194</id><is_i3>False</is_i3><isactive>False</isactive><isdirty>False</is
dirty><linkeddecscno>1013417424</linkeddecscno><marketsegment>34459527</marketsegment><marketsegmentname>EQU</marketsegmentname><newnid /><nocommreason>(None)</nocommre
ason><productno>518</productno><product_renamed>FREEW7-Freeview Bouquet W7</product_renamed><pslink>865628</pslink><reauthorize>False</reauthorize><rsnmodified>(None)</
rsnmodified><rsnfinanceoptionmodified>(None)</rsnfinanceoptionmodified><rsnpsrelink>(None)</rsnpsrelink><rsnreauthorize>(None)</rsnreauthorize><rsnspecialcsi>(None)</rs
nspecialcsi><rsnupdowngrade>(None)</rsnupdowngrade><scheduleeventno>0</scheduleeventno><setnid>False</setnid><specialcsi>False</specialcsi><contractstart>14 Jun 2011</c
ontractstart><status>Cancelled</status><warranty>14 Jun 2011</warranty><productuserkey>FREEW7</productuserkey><description>Freeview Bouquet W7</description><prdecscyn>0
</prdecscyn><smartcardyn>0</smartcardyn><noofunits>0</noofunits><producttype>D</producttype><lastordernumber>476413</lastordernumber><rsncaredisc /><price>0</price><amo
rtisationquote>0</amortisationquote><deposit>0</deposit><instalment>0</instalment><isprimaryproduct>False</isprimaryproduct><canCancel>True</canCancel><canDisconnect>Tr
ue</canDisconnect><canReconnect>True</canReconnect><discountProductprice>0</discountProductprice><discountProductuserkey /><isDiscount>0</isDiscount><Hash>D1-11-4E-98-7
5-D0-FC-99</Hash></Product><Product><accountno>40362150</accountno><contractenddate>29 Dec 2007</contractenddate><contractno /><contractperiod>1</contractperiod><custom
erno>36526867</customerno><dealer>36494076</dealer><dealername>3649407</dealername><dec_sclinked>False</dec_sclinked><dec_scmodel>W7PREM1-PREMIUM W7PREM1</dec_scmodel><
dec_scno>1013417424</dec_scno><dec_scstatus>(None)</dec_scstatus><financeoption>Subscription</financeoption><id>865629</id><is_i3>False</is_i3><isactive>True</isactive>
<isdirty>False</isdirty><linkeddecscno>1013417424</linkeddecscno><marketsegment>34459527</marketsegment><marketsegmentname>EQU</marketsegmentname><newnid /><nocommreaso
n>(None)</nocommreason><productno>423</productno><product_renamed>PRWFRNS-PremiumWestAfrica with French Bonus Bouq</product_renamed><pslink>865628</pslink><reauthorize>
False</reauthorize><rsnmodified>(None)</rsnmodified><rsnfinanceoptionmodified>(None)</rsnfinanceoptionmodified><rsnpsrelink>(None)</rsnpsrelink><rsnreauthorize>(None)</
rsnreauthorize><rsnspecialcsi>(None)</rsnspecialcsi><rsnupdowngrade>(None)</rsnupdowngrade><scheduleeventno>0</scheduleeventno><setnid>False</setnid><specialcsi>False</
specialcsi><contractstart>29 Nov 2007</contractstart><status>Active</status><warranty>29 Nov 2007</warranty><productuserkey>PRWFRNS</productuserkey><description>Premium
WestAfrica with French Bonus Bouq</description><prdecscyn>0</prdecscyn><smartcardyn>0</smartcardyn><noofunits>0</noofunits><producttype>D</producttype><lastordernumber>
476413</lastordernumber><rsncaredisc /><price>0</price><amortisationquote>0</amortisationquote><deposit>0</deposit><instalment>0</instalment><isprimaryproduct>True</isp
rimaryproduct><canCancel>True</canCancel><canDisconnect>True</canDisconnect><canReconnect>True</canReconnect><discountProductprice>0</discountProductprice><discountProd
uctuserkey /><isDiscount>0</isDiscount><Hash>4D-7A-69-28-2D-9A-4F-4D</Hash></Product><Product><accountno>40362150</accountno><contractenddate>29 Dec 2007</contractendda
te><contractno /><contractperiod>1</contractperiod><customerno>36526867</customerno><dealer>36494076</dealer><dealername>3649407</dealername><dec_sclinked>True</dec_scl
inked><dec_scmodel>W7PREM1-PREMIUM W7PREM1</dec_scmodel><dec_scno>1013417424</dec_scno><dec_scstatus>SOLD</dec_scstatus><financeoption>Sold</financeoption><id>865628</i
d><is_i3>False</is_i3><isactive>True</isactive><isdirty>False</isdirty><linkeddecscno>V105370851</linkeddecscno><marketsegment>34459527</marketsegment><marketsegmentnam
e>EQU</marketsegmentname><newnid /><nocommreason>(None)</nocommreason><productno>527</productno><product_renamed>PREM-Premium Smart Card</product_renamed><pslink>123643
4</pslink><reauthorize>False</reauthorize><rsnmodified>(None)</rsnmodified><rsnfinanceoptionmodified>(None)</rsnfinanceoptionmodified><rsnpsrelink>(None)</rsnpsrelink><
rsnreauthorize>(None)</rsnreauthorize><rsnspecialcsi>(None)</rsnspecialcsi><rsnupdowngrade>(None)</rsnupdowngrade><scheduleeventno>0</scheduleeventno><setnid>False</set
nid><specialcsi>False</specialcsi><contractstart>29 Nov 2007</contractstart><status>At Customer</status><warranty>28 Nov 2008</warranty><productuserkey>PREM</productuse
rkey><description>Premium Smart Card</description><prdecscyn>1</prdecscyn><smartcardyn>1</smartcardyn><noofunits>0</noofunits><producttype>I</producttype><lastordernumb
er>476364</lastordernumber><rsncaredisc /><price>0</price><amortisationquote>0</amortisationquote><deposit>0</deposit><instalment>0</instalment><isprimaryproduct>False<
/isprimaryproduct><canCancel>False</canCancel><canDisconnect>False</canDisconnect><canReconnect>False</canReconnect><discountProductprice>0</discountProductprice><disco
untProductuserkey /><isDiscount>0</isDiscount><Hash>27-4A-BD-EB-CE-E3-79-FF</Hash></Product></BusinessCollection><ControlNote><noteid>0</noteid><customerid>0</customeri
d><categoryid>0</categoryid><categorydesc /><controlnoteid>0</controlnoteid><notetype /><severitylevel>0</severitylevel><ispermanent>False</ispermanent><displaycode>0</
displaycode><notetext /><startdate /><enddate /><datecreated /><username /><createdby>0</createdby><iscurrent>False</iscurrent><Hash /></ControlNote><Add2 /><validtvodc
ustomer>True</validtvodcustomer><childAccCnt>0</childAccCnt><permissions><Authorised event='100'>True</Authorised><Authorised event='131'>True</Authorised></permissions
><showpopup>False</showpopup></xml></string> 

Open in new window

ASKER
Leon Taljaard

HI Qlemo,

I ended up using this with your initial advice but with just an extra tweak so that I could get the output into Orchestrator published data correctly.

if (!(Get-Variable ie -Scope global -ea SilentlyContinue) -or !$ie.Document)
{
  $global:ie = New-Object -comobject InternetExplorer.Application
}
$ie.silent  = $true
$ie.visible = $false

# First web site #

$Username = 'User Name'
$Password = 'Password'
$DSN = 'Value'

$ie.Navigate("http://Server/ibsv54/_Ws/context.asmx/Login?Username=$Username&Password=$Password&DSN=$DSN")
while ($ie.busy)                               { Start-Sleep -m 500 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 200 }

# Second web site #

$Token = 'Value'
$CustomerID ='Value'
$ie.Navigate("http://Server/ibsv54/_Ws/customer.asmx/LoadOverview?Token=$Token&CustomerId=$CustomerID")
while ($ie.busy)                               { Start-Sleep -m 500 }
while ($ie.Document.readyState -ne 'Complete') { Start-Sleep -m 200 }


$ie.Document.body.outertext -match '(\<xml\>.*\</xml\>)' | Out-Null; $matches[0] | Tee-Object -Variable a

Start-Sleep -m 5000

$ie.Quit()

Open in new window


Thank you very much for your help
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
Leon Taljaard

The help was great and I appreciate the help and patience
Qlemo

Thanks, and sorry that I had no time to work on http:#a41025342 to speed up things. On the other hand, that surely helped you in getting some understanding for future troubleshooting ;-).