PowerShell
PowerShell copied to clipboard
CreationTime date: Linux
Prerequisites
- [X] Write a descriptive title.
- [X] Make sure you are able to repro it on the latest released version
- [X] Search the existing issues.
- [X] Refer to the FAQ.
- [X] Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
What date is wrong?
PS > & {
>> $format = 'yyyy-MM-dd HH:mm:ss'
>> (Get-Date (stat -c %w /root) -f $format) + " # $(which stat) 'birth time'"
>> (Get-Item /root).CreationTime.ToString($format) + " # CreationTime"
>> (Get-Date (stat -c %y /root) -f $format) + " # $(which stat) 'last modified time'"
>> (Get-Item /root).LastAccessTime.ToString($format) + " # LastAccessTime"
>> (Get-Item /root).LastWriteTime.ToString($format) + " # LastWriteTime"
>> }
2021-03-10 22:31:43 # /usr/bin/stat 'birth time'
2022-06-04 23:48:49 # CreationTime
2022-06-04 23:48:49 # /usr/bin/stat 'last modified time'
2021-03-10 22:35:51 # LastAccessTime
2022-06-04 23:48:49 # LastWriteTime
Expected behavior
CreationTime must be equivalent to the native `stat` birth of file
Actual behavior
Creation time equivalent `stat` last modified time
Error details
No errors
Environment data
Name Value
---- -----
PSVersion 7.2.7
PSEdition Core
GitCommitId 7.2.7
OS Linux 6.0.5-arch1-1 #1 SMP PREEMPT_DYNAMIC Wed, 26 Oct 2022 15:25:45 +0000
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
PS. UnixStat also does not return proper datetime of file creation.
CreationTime comes from the .NET FileInfo type. If that value is incorrect, you'll need to open an issue here: https://github.com/dotnet/runtime
GitHub
.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps. - GitHub - dotnet/runtime: .NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
Yes, System.IO.DirectoryInfo and FileInfo give wrong information.
Can you check on latest pwsh build?
The same result, 7.3.0-rc.1
PS. But there is also good news, [console]::ReadKey() has learned to correctly recognize arrow keys ))
Can you check on latest pwsh build?
Problem still exists in PowerShell 7.4.0-preview.4. But as @SteveL-MSFT indicated, this is a .NET problem. See dotnet/runtime#42372.
The WG discussed this and agree this is a .NET issue.
This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.