Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: "String was not recognized as a valid DateTime." when running Import-VcConfigMgrApplication #138

Open
EvilGrinUK opened this issue Aug 31, 2023 · 2 comments

Comments

@EvilGrinUK
Copy link

EvilGrinUK commented Aug 31, 2023

Expected Behavior

Expect VcRedist to create application packages in SCCM.

Current Behavior

Error related to date format occurs when attempting to create the packages.

Failure Information (for bugs)

New-Item : Invalid operation
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.484\Public\Import-VcConfigMgrApplication.ps1:87 char:21
+ ...             New-Item -Path $DestCmFolder -ErrorAction "Continue" > $n ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (fssc02.uk.forbe...ation\VcRedists:String) [New-Item], WqlQueryException
    + FullyQualifiedErrorId : Path,Microsoft.PowerShell.Commands.NewItemCommand

Cannot find an overload for "Contains" and the argument count: "1".
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.484\Public\Import-VcConfigMgrApplication.ps1:125 char:29
+                         if ($PSBoundParameters.Contains($NoCopy)) {
+                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodException
    + FullyQualifiedErrorId : MethodCountCouldNotFindBest

WARNING: Failed to create application Visual C++ Redistributable for Visual Studio 2012 Update 4 x64.
New-CMApplication : Cannot convert value "8/31/2023" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.484\Public\Import-VcConfigMgrApplication.ps1:179 char:54
+                             $app = New-CMApplication @cmAppParams
+                                                      ~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-CMApplication], PSInvalidCastException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.ConfigurationManagement.PowerShell.Cmdlets.AppMan.NewApplication

Steps to Reproduce

  1. Installed latest VCRedist with Install-Module.
  2. Setu1p required folders
  3. Ran $VcList = Get-VcList -Export All | Save-VcRedist -Path "C:\Temp\VcRedist"
  4. Ran Import-VcConfigMgrApplication -VcList $VcList -CMPath "\uk\dfs\SCCMDeployments\VCRedist" -SMSSiteCode FS1

Context

The error relates to date formats. My locale is en-GB. Therefore my date format is dd/mm/yyyy rather than the usual mm/dd/yyyy en-US uses. I expect this is the confusion. Probably related to the fixes for #88

  • VcRedist version: 4.1.484
  • Powershell version: 5.1.14393.5582
  • OS: Windows Server 2016

Failure Logs

See above.

@aaronparker
Copy link
Owner

I've retested this in my lab. VcRedist uses the following code to determine the date value used for the ReleaseDate property in the app:

$(Get-Date -Format (([System.Globalization.CultureInfo]::CurrentUICulture.DateTimeFormat).ShortDatePattern))

In my test system, I had to logout and back in again for PowerShell to see the short date pattern correctly, even though the system was configured for en-AU:

image

@aaronparker
Copy link
Owner

aaronparker commented Sep 26, 2023

I don't think I can account for mismatched settings for the system vs. the user context, unless we play it safe and don't set the ReleaseDate property on the imported app (which is the import date, not the release date of the VcRedist).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants