Simple PowerShell LastWriteTime compare

前端 未结 7 925
我寻月下人不归
我寻月下人不归 2021-02-12 08:42

I need a PowerShell script that can access a file\'s properties and discover the LastWriteTime property and compare it with the current date and return the date differe

7条回答
  •  后悔当初
    2021-02-12 08:57

    Try the following.

    $d = [datetime](Get-ItemProperty -Path $source -Name LastWriteTime).lastwritetime
    

    This is part of the item property weirdness. When you run Get-ItemProperty it does not return the value but instead the property. You have to use one more level of indirection to get to the value.

提交回复
热议问题