Hi,
Please check to see if this works for you.
$input = "C:\temp\input.csv"
$output = "C:\temp\output.csv"
$objs = Import-Csv -Path $input
$properties = ($objs | Get-Member -MemberType NoteProperty).Name
$exclude = @()
foreach($property in $properties){
if(($objs.$property | where-object{$_}).count -eq 0){
$exclude += $property
}
}
$objs | Select-Object -Property * -ExcludeProperty $exclude | Export-Csv -NoTypeInformation -Path $output
Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.