first line getting added auto after running powershell script.

SURAJ KUMAR 41 Reputation points
2022-11-04T10:41:05.8+00:00

first line getting added auto after running powershell script. I don't want this line to be added in excel data.

257160-screenshot-46.png

$Csv = @"  
Parameter,Status  
ComputerName, DDPC1  
one,1  
two,2  
three,3  
four,4  
five,5  
"@ | ConvertFrom-Csv  
  
$NewCSV = @"  
$($csv.Parameter -join ',')  
$($csv.Status -join ',')  
"@ | ConvertFrom-Csv  
  
  
$NewCSV |Export-Csv -Path C:\test.csv   
Windows for business | Windows Server | User experience | PowerShell
0 comments No comments
{count} votes

Answer accepted by question author
  1. Andreas Baumgarten 129.2K Reputation points MVP Volunteer Moderator
    2022-11-04T11:32:26.84+00:00

    Hi @SURAJ KUMAR ,

    just add -NoTypeInformation to the Export-Csv cmd in line 17:

    $NewCSV | Export-Csv -Path C:\test.csv -NoTypeInformation  
    

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.