You need to pipe results to the Remove-Item or Move-Item. I tried it on my machine, it returns 2 and LastAccessTime is returned perfectly fine. Can you elaborate on your testing in the question, how do you verify that it returns LastWrtieTime but not LastAccessTime? Add a comment. Active Oldest Votes. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Post as a guest Name. Email Required, but never shown. The Overflow Blog. Stack Gives Back You cannot depend on the value of LastAccessTime to be accurate. What constitute access? Read metadata? Also, if the filesystem had to update that value for every access then it would be continuously busy updating the directory entry.
Updating the directory is a blocking operation. Idera uses cookies to improve user experience. Finally, the basic properties of the file display. To simplify the process of setting file time stamps, I created the following function. It accepts an array of file paths, and uses the current date and time for the new values. The Path parameter is a mandatory parameter.
This portion of the function is shown here:. It does not use the Recurse switched parameter, but if you want to add it, you could. For my purposes, I do not want it to Recurse, so I left the switch off. Next, the objects pass to the Foreach-Object cmdlet, and the three time stamp properties change to the new value. Join me tomorrow when we have a guest blog from Mike Robbins that talks about using Windows PowerShell with backups.
It is a cool blog. I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter microsoft. See you tomorrow. Until then, peace. Ed Wilson, Microsoft Scripting Guy. Comments are closed. Scripting Forums.
0コメント