I've been trying to wrap my head around this as I've attempted some solutions but could not get any of the work. Im currently trying to read a log file and input it into an array and then have it sort the array out into columns and the data underneath..
This is what I have so far:
$logFileArray = Get-Content -Path @("C:\Users\testuser\datatoparse.log")
foreach($item in $logFileArray)
{
write-host $item
}
$logFileArray | Export-CSV -Path "logfile.csv" -NoTypeInformation
Pause
An example of what is in the log file.
1 IKE Peer: 192.168.8.188 (PHX2)
Type : L2L Role : initiator
Rekey : no State : MM_ACTIVE
Encrypt : 3des Hash : SHA
Auth : preshared Lifetime: 86400
Lifetime Remaining: 52140
An example of what I want it to look like for the end result in the csv file
Any help or pointers would be much appreciated, thank you!
EDIT to show more example of the log file
1 IKE Peer: 192.168.8.188 (PHX2)
Type : L2L Role : initiator
Rekey : no State : MM_ACTIVE
Encrypt : 3des Hash : SHA
Auth : preshared Lifetime: 86400
Lifetime Remaining: 52140
2 IKE Peer: 192.168.8.189 (Worcester)
Type : L2L Role : initiator
Rekey : no State : MM_ACTIVE
Encrypt : aes-256 Hash : SHA
Auth : preshared Lifetime: 28800
Lifetime Remaining: 5929
3 IKE Peer: 192.168.8.190 (Fresno)
Type : L2L Role : initiator
Rekey : no State : MM_ACTIVE
Encrypt : aes-256 Hash : SHA
Auth : preshared Lifetime: 28800
Lifetime Remaining: 6564
4 IKE Peer: 192.168.8.191 (San Leandro)
Type : L2L Role : initiator
Rekey : no State : MM_ACTIVE
Encrypt : 3des Hash : SHA
Auth : preshared Lifetime: 86400
Lifetime Remaining: 71608