TFS Custom Extension Powershell script Parameters are not working

Welcome Forums General PowerShell Q&A TFS Custom Extension Powershell script Parameters are not working

Viewing 2 reply threads
  • Author
    Posts
    • #276963
      Participant
      Topics: 2
      Replies: 2
      Points: 29
      Rank: Member

      TFS Custom Extension Powershell script Parameters are not working inside a powershell Invoke script.

      I’ve a TFS Custom Extension which I’m developing, which has a invoke powershell script and the extension runs this script and it call
      powershell script inside the Invoke powershell script

      Script1

      sample code:
      invoke-TFS.ps1 has a if statements which executes the customScript.ps1 works fine except the TFS Variables are not working for the customScript.ps1 from TFS Agent.

      Script2
      The customScript.ps1
      Sample code:
      param($path, $path1)

      The Path and Path1 variables are passed through TFS Variables, The customScript.ps1 gets executed with all the debug statements added expect the arguments that are passed from the TFS Variables.

      Please suggest to resolve the TFS Variables.

      • This topic was modified 1 month, 2 weeks ago by info2m.
      • This topic was modified 1 month, 2 weeks ago by kvprasoon. Reason: Code formatting https://powershell.org/forums/topic/guide-to-posting-code-2/
    • #277035
      Senior Moderator
      Topics: 9
      Replies: 1449
      Points: 5,428
      Helping Hand
      Rank: Community MVP

      Are you getting any error ? How are you passing the TFS variables ? Can you share that too ?

      • #277755
        Participant
        Topics: 2
        Replies: 2
        Points: 29
        Rank: Member

        I’m not getting error, my release pipeline gets succeeded.

         

        Invoke-script.ps1 gets excuted

         

        if($script -eq $true)

        {

        .\CustomScript.ps1

        }

         

        my CustomScript.ps1 has param

        param($path, $path1)

        I’m passing both $path and $path1 as TFS Variables, some how the TFS Variables are not getting passed.

         

        how can i pass the argument in CustomScript.ps1?

        if($script -eq $true)

        {

        .\CustomScript.ps1 -ArgumentList $path $path1

        }

        Please let me know this work or no, if no how to pass the argument.

    • #277860
      Senior Moderator
      Topics: 9
      Replies: 1449
      Points: 5,428
      Helping Hand
      Rank: Community MVP

      .\CustomScript.ps1 -ArgumentList $path $path1

      Here is the problem.

      You have parameters defined as path1 and path2, so you should use the same name of the parameters while passing the value.

      and please use https://powershell.org/forums/topic/guide-to-posting-code-2/ for formatting the code in the forums.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.