现在,该文件正在解析中,我正在提取不同的信息,例如url,时间戳,网站标题等。一旦文件导出,则每列都会重复提取im信息。因此,将url,时间戳和网站标题放置在url列中,并且每隔一列都会发生
Get-Content 'C:\Users\nkwiecie\Downloads\Matched_hosts - Copy.csv' | ForEach-Object {
$url = Select-String -InputObject $_ -pattern "(bit\.ly|goo\.gl|tinyurl\.com)\S*\s"
$timestamp = select-string -InputObject $_ -pattern "((\d+(:|-))+\d+\D)+"
$Websitetitle = Select-string -InputObject $_ -pattern "(Web Page Title:).*?(Web Page Visit|Browser)"
$hostname = $_.split(",")
$username = select-string -InputObject $_ -pattern "(Username: ).*?\s"
Write-host "ORIGINAL = " $_
Write-host ""
Write-host "Found URL ===" $url.matches.value " | TIME STAMP === " $timestamp.matches.value " | FOUND WEBSITE TITLE === " $Websitetitle.matches.value " | HOSTNAME FOUND === " $hostname[0] " | USERNAME FOUND === " $username.matches.value
New-Object -Type PSObject -Property @{
'URL' = $url
'timestamp' = $Websitetitle
'websitetitle' = $Websitetitle
'hostname' = $hostname
'username' = $username
}
} | Export-Csv 'C:\Users\nkwiecie\Downloads\output.csv' -NoType