Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Time format in powershell

$
0
0

Hi

So, i'm not entirely sure if this is the right forum, but i have a weird problem with Powershell on my pc that i can't seem to solve.

Firstly, i run two different versions of powershell, i'm running both powershell 5 and 6.

Powershell 6

PS C:\windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      6.2.2
PSEdition                      Core
GitCommitId                    6.2.2
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

And powershell 5

PS C:\windows\system32> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.17763.592
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17763.592
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

In powershell 6, i have installed the AZ (Azure) module, and in powershell 5 i have the old azureRm module.

But for some weird reason, my powershell 5 have decided to change regional settings from my current Copenhagen settings to US, only for itself, as shown below.

PS 6:

PS C:\windows\system32> get-date Thursday, 8 August 2019 12.33.30


PS 5:

PS C:\windows\system32> get-date
Thursday, August 8, 2019 12:33:45 PM

This causes some command to give me an error, as if date in the selected command was $Null, eg. get-installedmodule.

4.1.3      AzureRM.TrafficManager              PSGallery            Microsoft Azure PowerShell - TrafficManager serv...
Cannot convert null to type "System.DateTime".
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7016 char:17+                 $InstalledDate = $null+                 ~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMetadataException+ FullyQualifiedErrorId : RuntimeException

4.0.5      AzureRM.UsageAggregates             PSGallery            Microsoft Azure PowerShell - UsageAggregates ser...
Cannot convert null to type "System.DateTime".
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7016 char:17+                 $InstalledDate = $null+                 ~~~~~~~~~~~~~~~~~~~~~~+ CategoryInfo          : MetadataError: (:) [], ArgumentTransformationMetadataException+ FullyQualifiedErrorId : RuntimeException

If trying the same command in PS6, it works like a charm, if i try it in Powershell ISE (PS5) it works like a charm. But in PS5, i errors out.

If i change my regional settings on the PC to be US, all of them works, but the second i change back, PS5 ignores it, and starts giving me an error again.

I have tried everything i can think of to fix this, but so far to no success.

have anyone experienced this issue, or even better, does anyone have a suggestion how to fix it?

Kind Regards
Martin


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>