microsoft / vscode-azureAutomation

MIT License
16 stars 4 forks source link

(PS Script) Datetime parameter with (Get-Date) default value works inconsistently between VSCode and Azure Portal #48

Open Volume999 opened 1 year ago

Volume999 commented 1 year ago

Reproduction steps:

  1. Make a powershell script with a Datetime parameter that has a (Get-Date) default value: param ( [Parameter()] [Datetime] $DateExample = (Get-Date) )
  2. Upload the script as draft to the portal
  3. Launch "Automation Test Job" (I have not tried publishing and testing that way but I assume it would work similarly)
    ----------- Job Status: Failed-------------
    ---------------  Output ----------------
    Exception : Cannot process argument transformation on parameter 'DateExample'. 
    Cannot convert value "(Get-Date)" to type "System.DateTime". Error: "String was not recognized as a valid DateTime."
  4. Launch the Test from the portal. For me, the runbook executed successfully

Expected result: Runbook works from the Test job launched in VSCode as well as the portal.

Configuration

OS Information: Edition Windows 11 Enterprise OS build 22621.1992

Product: Visual Studio Code Version: 1.80.1 Language: en