I'm trying to parse a .txt file in order to create a .csv, the issue is that the file is too big and I don't have similar characters in all the txt, so this is a short example:
Hostname:
xxx7
Network:
IPv4 Address = xxxx
IPv4 Netmask = xxxx
IPv4 Gateway = xxxx
DNS Servers = xxxx
Hostname:
xxxx-184
Network:
IPv4 Address = xxxx
IPv4 Netmask = xxxx
IPv4 Gateway = xxxx
DNS Servers = xxxx
Hostname:
xxxx-184
Network:
IPv4 Address = xxxx
IPv4 Netmask = xxxx
IPv4 Gateway = xxxx
DNS Servers = xxxx
Hostname:
xxxx-184
This txt file has got 500 lines. I think that if I could match one word like "hostname" i would be able to select the next line.
Something like:
$input = Get-Content C:\xxx\VNX\Audit_script\output\IP_info_all.txt
$array = @()
$input | foreach-object {
$writeobj = $true
$obj = New-Object System.Object
If ($_ -match 'Hostname*') {
$Hostname =
But I don't know how to select the line after Hostname.