Noah Lindenberger
Noah Lindenberger

Reputation: 1

Update-Timestamps Powershell command not working

Get-ChildItem -Path '\\folder_path\' -Recurse |
    Foreach-Object {
        (Get-Item $_.FullName).LastWriteTime=$(Get-Date -format o)
    }

Upvotes: 0

Views: 32

Answers (1)

boxdog
boxdog

Reputation: 8442

Your code is only updating the property in-memory. To change the actual file on disk, you'll need to use Set-ItemProperty. For example:

Set-ItemProperty -Path $_.FullName -Name LastWriteTime -Value (Get-Date)

Upvotes: 1

Related Questions