Original article address:Http://app.en25.com/e/es.aspx? S = 1403 & E = 4273 & elq = 1cbc05ed0b11413db47a3b65bc2ee7a4
Original article:
Changing file/Folder creation date
You shoshould use this approach if you need to change the creation time of a folder or file after you have created it:
Get-childitem c: \ testfolder | foreach-object {$ _. creationtime = '2017/24/60'
It will change creation time of c: \ testfolder to the date and time specified. note that the date-time format used here needs to match your local date-time format. A more general approach wocould be to use get-date with its parameters to construct a culture-neutral date and assign that to the file/folder creationdate property.
Translation:
Change the file or folder Creation Time
Use the following method to change the creation time of a created file or folder.
Get-childitem c: \ testfolder | foreach-object {$ _. creationtime = '2017/24/60'}
This sectionCodeWill changeC: \ testfolderIs a specified time. Note that the time format must be consistent with the time format of the local machine. The common practice is to useGet-DateAdd appropriate parameters to build a date and assign it to the creation date attribute of the file or folder.
Notes:
The original code has a problem,ForeachLess than one}End tag.
The logic of the original code is to change the creation date of all elements in a specified folder, so the title does not seem appropriate. However, the meaning is clearly expressed.
Below Cmdlet Usage: Get-childitem ( Strange why not Get-childrenitems) , Foreach-object ( No Foreach, Clearer )
Test found1972Such a date is displayed as null in the system, and it is normal to replace it with a relatively recent date.