I'm trying to create a spreadsheet that lists the LastWriteTime for hundreds of files and export this data to Excel. However, every time I try using the Export-Csv command, I encounter an error indicating that there's an unauthorized access issue. I suspect this is related to file permissions since LastWriteTime seems to be working fine. Interestingly, I've encountered similar issues on my personal PC as well. I'm using Windows 10 Pro x64 version 22H2.
1 Answer
Could you share the code you’re using? Also, make sure you're running PowerShell with Administrator privileges. Are you querying the directory recursively for 'C:Users'? That might be causing the issue.

Sure! Here's my basic code: Get-ChildItem -Path "\fs2userdatatolstikov_asDesktopTransmital" | Select Name, LastWriteTime | Export-Csv -Path "D:". When I try exporting to the same folder, I still get the same error regarding user privileges.