Export-Csv - Access to the path 'C:\export.csv' is denied Export-Csv - Access to the path 'C:\export.csv' is denied powershell powershell

Export-Csv - Access to the path 'C:\export.csv' is denied


You need to use an admin console or change the location of the csv file to C:\temp or something. The home drive require admin permissions.

powershell default vs admin

EDIT:The elevation requirement is only with system directories like:

C:\C:\WindowsC:\Program FilesC:\Program Files (x86)C:\Users

Notice that you can change C:\Users\<YourUserName> but not any other directories under C:\Users. Windows was built for multiple users even if you may be the only one using it. The above directories are common for all users and changing its contents would effectively change the Windows environment for other users too since windows rely on the integrity of these directories. Allowing a normal user to delete/modify/add files to these could have dangerous results for the OS and other people who use it.

So it tries to makes sure that only an Admin user is authorized to make changes to it. It is also the same reason why you get prompted for admin permissions when installing a software. It is installed to C:\Program Files or C:\Program Files (x86), make changes to the registry and is available to all users of that computer. Same with removing it. If a program does not require to do that, it doesn't require admin privileges. Eg: Portable softwares. Some programs only use the user directory or users temp directory C:\Users\<Username>\AppData\Local\Temp. Such programs are only available to the user that installed it.

If you have a custom directory like C:\myGames, adding files to it wont require elevation. So C:\Temp is just another directory like that. You will also notice that C:\ will let a normal user create a folder but not a file.

SUMMARY: Any changes that affect other user directories or the windows environment will require admin rights. Others don't.


In my case, the error occurred because I failed to specify the file name. The correct syntax is;

Export-Csv -path ".\targetList.csv"

and not -path "."