I have created custom data object that I output to csv. It all works fine, but how do I strip the header row from the output file? I've tried some variations of the "Select -Skip", but that usually generates a blank csv file. Here is the relevant bits of code:
#populate data row with user properties
$DataObject | Add-Member -MemberType NoteProperty -Name 'EventID'-Value $EventID
$DataObject | Add-Member -MemberType NoteProperty -Name 'Computer'-Value $env:COMPUTERNAME
$DataObject | Add-Member -MemberType NoteProperty -Name 'EngineerID' -Value $EngineerID
$DataObject | Add-Member -MemberType NoteProperty -Name 'UserID' -Value $UserID
$DataObject | Add-Member -MemberType NoteProperty -Name 'DateTime' -Value $DateTime
$DataObject | Add-Member -MemberType NoteProperty -Name 'StepCode' -Value $StepCode
$DataObject | Add-Member -MemberType NoteProperty -Name 'Result' -Value $Result
$DataObject | Add-Member -MemberType NoteProperty -Name 'Status' -Value $HomeDirectoryAccess
#export the dataobject to a CSV file
$OutputFile = ($OutFilePath + "\Status_" + $env:COMPUTERNAME + "_" + $DateStamp + "-" + $TimeStamp + ".csv")
$DataObject | Export-Csv -Path $OutputFile -NoTypeInformation
The $DataObject looks like this:
EventID : Test
Computer : MD-760R102
EngineerID : Jez
UserID : laijer
DateTime : 25/03/2015 12:24 PM
StepCode : USH
Result : Complete
Status : Home Drive Access Allowed
I've also tried this code to output the data, but it puts all the data into the 1st cell of the csv file instead of individual cells across a single row:
$DataOutput = $DataObject.EventID + "," + $DataObject.Computer + "," + $DataObject.EngineerID + "," + $DataObject.UserID + "," + $DataObject.DateTime + "," + $DataObject.StepCode + "," + $DataObject.Result + "," + $DataObject.Status
$DataOutput | Out-File $OutputFile