Reputation: 3986
I have powershell v2. I am getting below error.
Unable to find type [cultureinfo]: make sure that the assembly containing this type is loaded.
Can anybody encounter this error before? My script is working fine on powershell v3 but in my server its PS v2 and i can't upgrade it.
This is the command which i am running.
$log_date = [datetime]::ParseExact('Tue Aug 4 17:05:41 2015','ddd MMM d HH:mm:ss yyyy',[cultureinfo]::InvariantCulture,'AllowInnerWhite')
Upvotes: 1
Views: 986
Reputation: 109035
Only a few namespaces are included in PowerShell's search for type names (and the list expands from version to version).
And System.Globalization
(which contains CultureInfo
) is not one.
But the resolution of names is relative to those namespaces that PowerShell defaults, so you can use [Globalization.CultureInfo]
.
Upvotes: 3