在 Powershell 中一次设置多个属性
有没有比这更短的方法可以在 Powershell 中通过一个命令将多个属性设置为相同的值?
示例:
(gi "c:\test.txt").LastWriteTime = (gi "c:\test.txt").LastAccessTime = (gi "c:\test.txt").CreationTime = Get-date
我只是好奇是否有办法缩短此语法。
Is there a shorter way to set multiple properties to the same value in Powershell in one command than this?
Example:
(gi "c:\test.txt").LastWriteTime = (gi "c:\test.txt").LastAccessTime = (gi "c:\test.txt").CreationTime = Get-date
I'm just curious if there is a way to shorten this syntax.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用了 Mjolinor 答案的稍微修改版本来解决刚刚从远程源下载的文件日期不正确的问题。我修改了代码,使其更清晰易懂,以防将来我必须返回(将简写更改为完整的命令名称)。
I've used a slightly modified version of Mjolinor's answer to solve a problem I had of incorrect date on files that had just been downloaded from a remote source. I modified the code to make it cleaner to understand in case I have to come back to in the future (changed the short hand to full command names).