I am trying to execute a PowerShell file from Windows CMD using below command.
powershell -NoProfile -NonInteractive -ExecutionPolicy ByPass -File C:\Users\akarri\Desktop\Temp\test1.ps1 -ConfigPathsArray @(1,2,4)
PowerShell code:
Param(
[Parameter(Mandatory=$True,Position=0)]
[Object[]] $ConfigPathsArray
)
function Start-Transform($configsArray) {
[Object[]] $test = @(1,2,4)
$test.GetType()
foreach ($configArray in $test) {
Write-Output $configArray
}
$configsArray.GetType()
foreach ($configArray in $configsArray) {
Write-Output $configArray
}
}
Start-Transform -configsArray $ConfigPathsArray -Verbose
Though I am passing an array from CMD, the count of $configPathsArray is giving me is 1.
It is working fine when I execute the command with -Command option instead of -File but I need your help in executing the same with -File command (Working with TeamCity Enterprise 2019.1.1 (build 66192))