I would like to know how to ignore warning/error popups while running Powershell for Excel com objects. However I’d still like the errors to be logged in the Powershell console (as it is with my current code below).
I’m running the following code as of now:
$files = Get-ChildItem -Path "D:\Product Feeds\" *.xlsx -Recurse $xl = New-Object -ComObject Excel.Application foreach ($file in $files) { $newFile = "$($file.DirectoryName)\$($file.BaseName).csv" $wb = $xl.Workbooks.Open($file.FullName) $wb.RefreshAll() if (Test-Path -Path $newFile) { Remove-Item $newFile -Force } $wb.SaveAs("$newFile",6) $wb.Close($true) } [System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl)
Thanks in advance