Here is the code i use… It works in the way i want it to work… It finds a description that equals 8.1.1.1 and deletes everything that contains in it…
$text = gc H:\nessusfile.audit
$text = $text -split “`r`n”,‘’
$delete = $false
$op = @()
foreach($line in $text)
{
if($line -like '**')
{
$itemLines = @($line)
$delete = $false
$inItem = $true
continue
}
elseif($line -like '**')
{
$itemLines += $line
if($delete -eq $false)
{
$op += $itemLines
}
$inItem = $false
continue
}
if($inItem)
{
$itemLines += $line
if($line -like '*description *: *8.1.1.1*')
{
$delete = $true
}
}
else
{
$op += $line
}
}
$op | out-file "H:\Test.audit"
The issue is… When i tried to upload the file to Tenable Security Center it says “Invalid Format”… Naming convention is the same…
I think it has something to do with
$text = $text -split "`r`n",''
When i do not use that line of code the script does not work… Is there a way to fix this issue i am having?