Trying to user PowerShell to parse and scrape a webpage, a type of s/w inventory mgmt site we have, with below code
$test = Invoke-WebRequest -UseBasicParsing -Uri https://testuser -UseDefaultCredentials
$test.ToString() -split "[`r`n]" |
Select-String "Usbser.sys" |
ConvertFrom-StringData
It works except that I also need version of s/w I am searching for.
Current output:
Name Value
---- -----
<td class "info">Usbser.sys </td
$test.ToString()
gives me below data:
<td class="info">Usbser.sys </td>
<td class="info">10.0.16299.334</td>
How do I crop off those tags from current output and also have it display the version info 10.0.16299.334?
Edit1: So I managed to find class as suggested by Lieven
className :
id : installedSoftwareContainer
tagName : DIV
parentElement : System.__ComObject
style : System.__ComObject
onhelp :
onclick :
ondblclick :
onkeydown :
onkeyup :
onkeypress :
onmouseout :
onmouseover :
onmousemove :
onmousedown :
onmouseup :
document : mshtml.HTMLDocumentClass
title :
language :
onselectstart :
sourceIndex : 1496
recordNumber :
lang :
offsetLeft : 0
offsetTop : 0
offsetWidth : 0
offsetHeight : 0
offsetParent :
innerHTML :
<table width="100%" border="1" cellspacing="0" cellpadding="5">
<tbody><tr>
<td class="caption">Name</td>
<td class="caption">Version</td>
</tr>
<tr>
<td class="info">1E NomadBranch x64</td>
<td class="info">6.3.201</td>
InnerText : 1E NomadBranch x646.3.201
but when I try the below code, I get nothing
$test = Invoke-WebRequest -Uri https://testurl.com -UseDefaultCredentials
$test.ParsedHtml.getElementbyid('installedsoftwarecontainer') | select innertext
What am I doing wrong?