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 Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,359 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 96,036 Reputation points MVP
    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