I have been using a script to import a data.tsv file into Excel which creates a workbook then closes it. It worked in PowerShell 4 under Windows 8.1. I've upgraded to Windows 10 with PowerShell 5. Now it is no longer working.
As far as I can tell, by debugging line by line in ISE, it is this line:
$xl.Workbooks.OpenText($importcsv)
The script:
#Import to xlsx
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$wbpath=Join-Path "$psscriptroot" 'data.xlsx'
$importcsv=Join-Path "$psscriptroot\CPU\" 'data.tsv'
$xl = New-Object -ComObject Excel.Application
$xl.Visible = $false
$xl.Workbooks.OpenText($importcsv)
$xl.DisplayAlerts = $false
[threading.thread]::CurrentThread.CurrentCulture = 'en-US'
$xl.ActiveWorkbook.SaveAs($wbpath,51)
$xl.Quit()
while([System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl)){'released'}
If I run the script, it just hangs. It opens Excel in the background and just sits there. No errors.
Any ideas?