Powershell: Change file attributes automatically when copying

删除回忆录丶 提交于 2019-12-10 17:01:06

问题


I have a folder of read only files. When I copy one of these files to a test location, I want to be able to copy them and not retain their original attributes.

I can do this, but this is lengthy.

copy-item srcfilefullname destfilefullname
set-itemproperty destfilefullname -isreadonly $false

I did not find anything in the documentation for copy-item. I am hoping there is a shorter way.

Thanks
Steeluser


回答1:


Your intention is not very clear. If you want to build a one-liner from that, try this (NOT TESTED):

copy-item srcfilefullname (set-itemproperty srcfilefullname -isreadonly $false -passthru).fullname

PassThru parameter allows Set-ItemProperty to generate and return a PSCustomObject.



来源:https://stackoverflow.com/questions/5924233/powershell-change-file-attributes-automatically-when-copying

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!