Hey everyone,
Here is my issue. I have a Powershell v2.0 application that I created using Sapien Powershell Studios, that sends information to a CSV. Then I have another script(batch) that reads the CSV, but does not find any information until I physically open the CSV file, save, and close the file. The information does indeed go to the CSV I have confirmed that. Does anyone have any ideas? I have posted my code below.
Powershell
Out-File -Append -FilePath $namesFile -InputObject @(" ") Out-File -Append -FilePath $namesFile -InputObject @($tfPO.Text + "," + $tfLoc.Text + ", Qty: " + $qty.Text + ", ," + $username) Out-File -Append -FilePath $namesFile -InputObject @(" ")
for ([int]$i = 0; $i -lt $datagrid.RowCount; $i++) { Out-File -Append -FilePath $namesFile -InputObject @($datagrid.Rows[$i].Cells['Serial'].Value + "," + $datagrid.Rows[$i].Cells['Hostname'].Value + "," + $cbType.SelectedItem.ToString() + "," + $cbImage.SelectedItem.ToString()) }
Batch(I know this works fine)
FOR /F "delims=, tokens=2,3,4" %%A in ('type y:\names.csv ^| FIND /i "%Serial%"') do Set Model=%%CI have also tried to utilize the Type command by itself thru command prompt. I am also looking for a work around that will open the CSV, save and close or similar. Here are the ones that I have tried that have not worked.
Get-Content
$file = Get-ChildItem -LiteralPath $namesfile $stream = $file.OpenRead() $stream.Close()
Any help would be awesome. Thanks!