'Terraform Azure VM Extension failed with too long command for Powershell script execution

I am getting below error while executing the Azure VM extension in Terraform for run Powershell script. Could you please help me to solve this error?

Command execution finished, but failed because it returned a non-zero exit code of: '1'. The command had an error output of: 'The command line is too long. '

Here is the protected settings details which is I used

"commandToExecute": "powershell -command \"[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String('${base64encode(data.template_file.secvmtf.rendered)}')) | Out-File -filepath hybrid.ps1\" && powershell -ExecutionPolicy Unrestricted -File hybrid.ps1"


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source