Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting multiple properties at once in Powershell

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.

like image 778
Yots Avatar asked May 25 '11 21:05

Yots


1 Answers

"CreationTime","LastWriteTime","LastAccessTime" |% {(gi test.txt).$_ = (get-date)}
like image 105
mjolinor Avatar answered Sep 18 '22 00:09

mjolinor