You know that top line when you export from Powershell? Here is how to remove it from an entire folder of CSVs (just put the content in you need to search)
# Set the path to the folder containing CSV files
$folderPath = "D:\powershell\output"
# Get all CSV files in the folder
$csvFiles = Get-ChildItem $folderPath -Filter *vms.csv
# Loop through each CSV file
foreach ($file in $csvFiles) {
# Read the CSV file as an array of strings
$lines = [System.IO.File]::ReadAllLines($file.FullName)
# Check the top line for a match
if ($lines[0] -match '#TYPE Microsoft.Azure.Commands.Compute.Models.PSVirtualMachineList') {
# Remove the first line
$lines = $lines[1..($lines.Length-1)]
# Write the modified lines back to the CSV file
[System.IO.File]::WriteAllLines($file.FullName, $lines)
}
}
You could adjust the output but that seems to vary allot…