Export-Csv-拒绝访问路径'C:\ export.csv' [英] Export-Csv - Access to the path 'C:\export.csv' is denied

查看:488
本文介绍了Export-Csv-拒绝访问路径'C:\ export.csv'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在获取所需的信息,尽管当我导出信息时遇到错误.

I'm getting the information I need out of the line, although when I go to export the information, I get an error.

当我运行此代码时:

get-process | Export-csv -Path "C:\export.csv" -NoTypeInformation

我收到此错误:

Export-csv : Access to the path 'C:\export.csv' is denied.
At line:1 char:14
+ get-process | Export-csv -Path "C:\export.csv" -NoTypeInformation
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

如何导出为CSV?

推荐答案

您需要使用管理控制台或将csv文件的位置更改为C:\temp或其他名称.主驱动器需要管理员权限.

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.

海拔要求仅适用于系统目录,例如:

The elevation requirement is only with system directories like:

C:\
C:\Windows
C:\Program Files
C:\Program Files (x86)
C:\Users

请注意,您可以更改C:\Users\<YourUserName>,但不能更改C:\Users下的任何其他目录. Windows是为多个用户构建的,即使您可能是唯一使用Windows的用户.上面的目录对所有用户而言都是公用的,并且由于Windows依赖于这些目录的完整性,因此更改其内容也将有效地更改其他用户的Windows环境.允许普通用户删除/修改/添加文件会给操作系统和其他使用该文件的人带来危险.

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.

因此,它试图确保只有管理员用户才有权对其进行更改.这也是安装软件时提示您获得管理员权限的相同原因.它安装到C:\Program FilesC:\Program Files (x86),对注册表进行更改,并且可供该计算机的所有用户使用.与删除它相同.如果程序不需要这样做,则不需要管理员权限.例如:便携式软件.某些程序仅使用用户目录或用户temp目录C:\Users\<Username>\AppData\Local\Temp.此类程序仅对安装它的用户可用.

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.

如果您具有C:\myGames之类的自定义目录,则向其添加文件将不需要提升.因此,C:\Temp只是这样的另一个目录.您还会注意到,C:\将允许普通用户创建文件夹,而不是文件.

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.

摘要:影响其他用户目录或Windows环境的任何更改都将需要管理员权限.其他人没有.

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

这篇关于Export-Csv-拒绝访问路径'C:\ export.csv'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆