Well that gave me an interesting csv. I'm guessing I put your suggestion in the wrong place.
Get-VM -PipelineVariable vm |
ForEach-Object -Process {
$obj = @{
VM = $vm.Name
}
if($vm.Notes){
$vm.Notes.Split("`n") | where{$_ -ne ''} |
ForEach-Object -Process {
$name,$value = $_.Split(':=')
if($obj.ContainsKey($name)){
Write-Host "VM $($vm.Name) seems to have multiple entries for $name"
}
else{
$obj.Add($name,$value)
}
}
}
else{
Write-Host "VM $($vm.Name) has no notes"
}
try{
New-Object -Typename psobject -Property $obj -ErrorAction Stop
}
catch{
Write-Host "Error creating the object for VM $($vm.Name)"
$obj.GetEnumerator()
}
} | Sort-Object -Property {($_ | Get-Member).Count} -Descending |
Export-Csv -Path .\report-noblank.csv -NoTypeInformation -UseCulture
CSV:
How about we ask for those lines in notes that have verbiage with a colon separator? From the looks of it, someone has filesystem information recorded in notes. Skip everything that isn't prefaced with XYZ: (XYZ could be anything as long as it's followed by a colon).