0
function deployapp(){
    Param
    (
         [Parameter(Mandatory=$true)]
         [string] $dest_api,
         [Parameter(Mandatory=$true)]
         [string] $a_api,
         [Parameter(Mandatory=$true)]
         [string] $data_api
        # [Parameter(Mandatory=$true)]
        # [string] $destserver
    )
    Write-Host $b_api
    Write-Host $c_api
    Copy-Item -Path $b_api -Destination "F:\output" -Recurse
    Copy-Item -Path $g_api -Destination "F:\output" -Recurse
    Copy-Item -Path $r_api -Destination "F:\output" -Recurse


}

[String]$et_api = "Senv:chocolateyPackageFolder\\.et.api"
Write-host $et_api
[String]$d_api="Senv:chocolateyPackageFolder\.et_api"
[String]$data_api="Senv:chocolateyPackageFolder\.et_data.api"
deployapp $d_api,$d_pi,$et_data_api

After triggering the command `choco install --force -api-et-api -y

It is showing followuing error

ERROR: Cannot process argument transformation on parameter 'desapi'. Cannot convert value to type System.String.
The install of -api-et-api was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\-api-et-api\tools\chocolateyinstall.ps1'.

After triggering the command `choco install --force api-et-api -y

It is showing followuing error

ERROR: Cannot process argument transformation on parameter 'et_api'. Cannot convert value to type System.String.
The install of api-et-api was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\api-et-api\tools\chocolateyinstall.ps1'.
 See log for details.

I have tried with typeconversion in both explicit and implicit way but it did not work. Can choclatey env parameter end as paramter?

  • 1
    remove the brackets and commas from the function call `deployhProject($service_ebusiness_api,...)`. PowerShell user `spaces` – Theo Aug 21 '21 at 18:23
  • In short: PowerShell functions, cmdlets, scripts, and external programs must be invoked _like shell commands_ - `foo arg1 arg2` - _not_ like C# methods - `foo('arg1', 'arg2')`. If you use `,` to separate arguments, you'll construct an _array_ that a command sees as a _single argument_. To prevent accidental use of method syntax, use [`Set-StrictMode -Version 2`](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/set-strictmode) or higher, but note its other effects. See [this answer](https://stackoverflow.com/a/65208621/45375) for more information. – mklement0 Aug 21 '21 at 18:31
  • @Theo no. That portion is commented out – MD. Ashfaqur Rahman Tahashin Aug 21 '21 at 18:31
  • 1
    @MD.AshfaqurRahmanTahashin, it's not the parentheses that are the problem, it's passing what you intend to be _separate_ arguments with `,` as the separator, which instead passes a _single_ argument that is an _array_. – mklement0 Aug 21 '21 at 18:32
  • @mklement0 that error is solved getting new error Cannot find drive. A drive with the name 'Senv' does not exist. – MD. Ashfaqur Rahman Tahashin Aug 21 '21 at 18:55
  • 1
    [about Environment Variables](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_environment_variables) – Theo Aug 21 '21 at 19:03
  • 1
    `Senv` -> `$env` - see Theo's link. – mklement0 Aug 21 '21 at 19:12
  • 1
    @mklement0 did it and it is executing nicely now thanks – MD. Ashfaqur Rahman Tahashin Aug 21 '21 at 19:29

0 Answers0