- This topic has 2 replies, 3 voices, and was last updated 1 month, 2 weeks ago by
April 16, 2020 at 3:43 pm #219666ParticipantTopics: 1Replies: 1Points: 15Rank: Member
For years, I’ve been using the following PowerShell code in my profile file to make sure I’m using ISO 8601 format for date.
$culture = Get-Culture $culture.DateTimeFormat.ShortDatePattern = 'yyyy-MM-dd' Set-Culture $culture
I’ve just installed PowerShell 7 and suddenly this code does not work anymore. I got this error message:
2 | $culture.DateTimeFormat.ShortDatePattern = ‘yyyy-MM-dd’
| Exception setting “ShortDatePattern”: “Instance is read-only.”
So, what is the new and correct way of doing this in PowerShell 7? Please.
April 16, 2020 at 4:03 pm #219678ParticipantTopics: 4Replies: 2247Points: 5,484Rank: Community MVP
When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to you help making their work twice or more.
April 16, 2020 at 5:58 pm #219729ParticipantTopics: 3Replies: 340Points: 1,120Rank: Community Hero
This is interesting. Based on the closed issue linked below, it is being stated that it’s read only, always has been, not a bug, and working as designed.
However that is not true, in 5.1 you are able to set it the way you show.
<p style=”text-align: left;”>https://imgur.com/VXXYwar</p>
Now I thought I was onto something with this
As you can see it didn’t error but it didn’t change either. I’d say there is a bug, either in Windows Powershell for it working, or in pwsh 6/7 for it not.I tested on 6.2.1
- You must be logged in to reply to this topic.