Sorry I couldn’t find any topic related to this matter.
When I try to use export-csv to an already existing, hidden file, I get the error. As you see I use -force switch.
If I unhide the file it works well.
Export-Csv : Access to the path 'E:\Users\ao\Desktop\result.csv' is denied. At line:1 char:13 + Get-Process|Export-Csv -Path .\result.csv -force + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OpenError: (:) [Export-Csv], UnauthorizedAccessException + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ExportCsvCommand
the original command takes a while to output data to the csv file and I want it to be hidden so I created the file beforehand and hid it, as I couldn’t find a switch for export-csv to hide the file when it creates it. there’s no point hiding the file, as after export-csv is done, the file gets read and deleted which is happening far more faster.
I want to hide the file during the output process.
Any suggestion appreciated.