Learn the fundamentals of the popular programming language JavaScript so that you can explore the realm of web development.
Do more with
Function Get-McAfeeItem {
Param(
[String]$Url,
[String]$Filter,
[Switch]$Debug
)
$NameFilter = If ($Filter) {{$_.Name -like $Filter}} Else {{$true}}
$DTProvider = New-Object -TypeName System.Globalization.CultureInfo -ArgumentList 'en-US'
$DTFormat = 'M/d/yyyy h:mm tt'
$Content = Invoke-WebRequest -Uri $Url | Select-Object -ExpandProperty Content
If ($Debug) {$Content | Set-Content -Path "$((Get-Location -PSProvider FileSystem).Path)\McAfeeContent.html"}
$Content.Replace("`r`n", ' ') -replace '\s+', ' ' -split '<br>' |
Where-Object {$_ -match '\s*(?<Date>.*?)\s*(?<Size>\d+?)\s*<A\s+HREF\s*=\s*"(?<Path>.*?)"\s*>\s*(?<Name>.*?)</A>'} |
Select-Object -Property `
@{n='Name'; e={$Matches['Name']}},
@{n='Size'; e={[int64]$Matches['Size']}},
@{n='Date'; e={[DateTime]::ParseExact($Matches['Date'], $DTFormat, $DTProvider)}},
@{n='Path'; e={$Matches['Path']}} |
Where-Object $NameFilter
}
Get-McAfeeItem -Debug -Url "mcafee.acme.com/css_content/current/VSCANDAT1000/DAT/0000/" -Filter avvdat.ini | Select-Object -ExpandProperty Date
Premium Content
You need an Expert Office subscription to comment.Start Free Trial