Updated scripts

Added -Header parameter and scoped the header variable in the
Export-Excel command
This commit is contained in:
dfinke
2016-03-02 18:03:00 -05:00
parent 22326e8ee4
commit e9b8deccf5
6 changed files with 33 additions and 16 deletions

View File

@@ -2,18 +2,19 @@ function Get-HtmlTable {
param(
[Parameter(Mandatory=$true)]
$url,
$tableIndex=0
$tableIndex=0,
$Header
)
$r = Invoke-WebRequest $url
$table = $r.ParsedHtml.getElementsByTagName("table")[$tableIndex]
$propertyNames = @()
$propertyNames=$Header
$totalRows=@($table.rows).count
for ($idx = 0; $idx -lt $totalRows; $idx++) {
for ($idx = 1; $idx -lt $totalRows; $idx++) {
$row = $table.rows[$idx]
$cells = @($row.cells)
$cells = @($row.cells)
if(!$propertyNames) {
if($cells[0].tagName -eq 'th') {
@@ -22,7 +23,7 @@ function Get-HtmlTable {
$propertyNames = @(1..($cells.Count + 2) | % { "P$_" })
}
continue
}
}
$result = [ordered]@{}