[Bug] $adtSession.AppScriptDate Must In Yyyy-mm-dd Format

by ADMIN 58 views

Prerequisites

Before filing a new issue, ensure you have completed the following steps:

PSAppDeployToolkit version

The version of PSAppDeployToolkit used to reproduce the issue is 4.0.6.

Describe the bug

In the Invoke-AppDeployToolkit.ps1 script, the $adtSession.AppScriptDate is parsed by the toolkit. However, if the date format does not meet the required YYYY-MM-DD format, it fails with the following error:

Open-ADTSession: Unable to process argument transformation on parameter 'AppScriptDate'. Cannot convert value '14.05.2025' to type 'System.DateTime'. Error: 'String was not recognized as a valid DateTime.'
At C:\TEMP\TemplateAppDeployment\TemplateAppDeployment\Invoke-AppDeployToolkit.ps1:272 : 84
+ ... sion -SessionState $ExecutionContext.SessionState @adtSession @iadtPa ...
+                                                       ~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (:) [Open-ADTSession], ParameterBindingArgumentTransformationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Open-ADTSession

The error occurs because the date format '14.05.2025' is not recognized as a valid DateTime by the toolkit.

Steps to reproduce

To reproduce the issue, follow these steps:

  1. Create a new package using the New-ADTTemplate cmdlet:

New-ADTTemplate -Destination C:\Temp\TemplateAppDeployment -Name "TemplateAppDeployment"


2.  Modify the `Invoke-AppDeployToolkit.ps1` script to set the `AppScriptDate` to a date in the wrong format (e.g., '14.05.2025'):

    ```powershell
AppScriptDate = '14.05.2025'
  1. Run the script.

Environment data

The environment data used to reproduce the issue is as follows:

OsName               : Microsoft Windows 11 Entreprise
OSDisplayVersion     : 23H2
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64 bits
WindowsVersion       : 2009
WindowsProductName   : Windows 10 Enterprise
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : fr-FR
OsMuiLanguages       : {fr-FR}
KeyboardLayout       : fr-CH
TimeZone             : (UTC+01:00) Amsterdam, Berlin, Berne, Rome, Stockholm, Vienne
HyperVisorPresent    : True
CsPartOfDomain       : True
CsPCSystemType       : Desktop

Impact

The issue has a significant impact on the functionality of the PSAppDeployToolkit, as it prevents the from parsing the date correctly. This can lead to errors and failures in the deployment process.

Solution

To resolve the issue, the toolkit should be modified to handle date formats other than YYYY-MM-DD. This can be achieved by adding additional date formats to the parsing logic or by using a more flexible date parsing library.

Workaround

As a workaround, users can modify the date format in the Invoke-AppDeployToolkit.ps1 script to match the required YYYY-MM-DD format. For example:

AppScriptDate = '2025-05-14'

However, this workaround may not be feasible in all scenarios, and a more robust solution is required to resolve the issue.

Conclusion

Frequently Asked Questions

Q: What is the issue with the $adtSession.AppScriptDate?

A: The issue is that the $adtSession.AppScriptDate is not being parsed correctly by the toolkit because it is not in the required YYYY-MM-DD format.

Q: What is the required format for the $adtSession.AppScriptDate?

A: The required format for the $adtSession.AppScriptDate is YYYY-MM-DD.

Q: What happens if the date format is not in the required format?

A: If the date format is not in the required format, the toolkit will fail with an error message indicating that the date string was not recognized as a valid DateTime.

Q: How can I reproduce the issue?

A: To reproduce the issue, follow the steps outlined in the "Steps to reproduce" section of the original bug report.

Q: What is the impact of this issue?

A: The issue has a significant impact on the functionality of the PSAppDeployToolkit, as it prevents the toolkit from parsing the date correctly. This can lead to errors and failures in the deployment process.

Q: Is there a workaround for this issue?

A: Yes, there is a workaround for this issue. Users can modify the date format in the Invoke-AppDeployToolkit.ps1 script to match the required YYYY-MM-DD format.

Q: What is the solution to this issue?

A: The solution to this issue is to modify the toolkit to handle date formats other than YYYY-MM-DD. This can be achieved by adding additional date formats to the parsing logic or by using a more flexible date parsing library.

Q: Why is this issue important?

A: This issue is important because it affects the functionality of the PSAppDeployToolkit, which is a critical tool for deploying applications. The issue can lead to errors and failures in the deployment process, which can have significant consequences for the organization.

Q: How can I get help with this issue?

A: If you are experiencing issues with the $adtSession.AppScriptDate, you can get help by:

  • Searching the GitHub repository for existing issues and solutions
  • Posting a question on the GitHub issues page
  • Reaching out to the PSAppDeployToolkit community for support

Additional Resources