My form is getting last boot time from remote machine as follows:
$lastboot = (Get-WmiObject win32_operatingsystem | select csname, @{LABEL = 'LastBootUpTime'; EXPRESSION = { $_.ConverttoDateTime($_.lastbootuptime) }}).lastbootuptime
$richtextboxLastBoot.Text = $($lastboot)
When I run in Powershell I get the expected result - I am in the UK
01 March 2020 00:53:50
When I run it in the Powershell studio GUI it is returning the following in US date format:
03/01/2020 00:53:50
Any ideas?
Powershell studio handling dates differently to powershell ISE
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
- Alexander Riedel
- Posts: 8479
- Last visit: Thu Mar 28, 2024 9:29 am
- Been upvoted: 37 times
Re: Powershell studio handling dates differently to powershell ISE
The PowerShell console behaves differently than other hosts, even the ISE.
It's probably best to take full control of that in your script.
Set-Culture "en-GB"
is probably a good bet.
Then using
$d = Get-Date
$d.GetDateTimeFormats()
You can see the various formats available
I am guessing
$d = Get-Date
$d.GetDateTimeFormats()[25]
would be what you look for.
It's probably best to take full control of that in your script.
Set-Culture "en-GB"
is probably a good bet.
Then using
$d = Get-Date
$d.GetDateTimeFormats()
You can see the various formats available
I am guessing
$d = Get-Date
$d.GetDateTimeFormats()[25]
would be what you look for.
Alexander Riedel
SAPIEN Technologies, Inc.
SAPIEN Technologies, Inc.
Re: Powershell studio handling dates differently to powershell ISE
awesome that works a treat, thank you