Script below, I need some help because the output to CSV is not clean, meaning I want the EID’s to be in one column and the vendorname to be in the column next to EID. Thanks!
$obj = @()
$s = NETAssignmentsModified
$s | ConvertTo-Json
Foreach($_ in $s){
}
$obj += [PSCustomObject]@{ #breakout all the essential object items
EID = $.specialbill.id -as [String]
Vendor = $.vendorName -as [String]
When you post code, error messages, sample data or console output format it as code, please.
In the “Text” view you can use the code tags “PRE”, in the “Visual” view you can use the format template “Preformatted”. You can go back edit your post and fix the formatting - you don’t have to create a new one.
Thanks in advance.
What is “NETAssignmentsModified”? Is it a string? What result would you expect when you convert a string into JSON? You should not use $_ as a variable for yourself. It’s the pipeline variable and should not be used for something else. If you had saved a collection you could iterate over in a variable named $s your code could look like this:
Hello,
Below script is working now but the data in the CSV is all duplicates of the first record/object. Curious why the data is repeating when it should be unique record for each object in the base variable.
$obj = @()
$base = NETAssignmentsModified
For ($i=1; $i -le 20000; $i++){
Foreach($b in $base){
}
$result = $obj += [PSCustomObject]@{
#breakout all the essential object items
EID = $b.specialbill.id -as [String]
Vendor = $b.vendorName -as [String]
}
$result|export-csv -path "c:\users\BWiley\MyData$((Get-Date).ToString("MMddyyyy")).csv" -NoTypeInformation
}