Sunday, December 27, 2020

Power shell script Save the csv headers from the file


-Recurse recurses through folders.. and   write to Out_Headers.txt 


 Get-ChildItem -Path . -Recurse -Filter '*.csv' |

ForEach{

     $PSItem |

     Select-Object -Property FullName,

     @{Name = 'FirstLineOfFile';Expression = {Get-Content -Path $PSItem.FullName -First 1}}

 } |Out-File Out_Headers.txt -Append


No comments: