Delay-Bind: Is it possible to prevent binding unless a scriptblock is used?

Welcome Forums General PowerShell Q&A Delay-Bind: Is it possible to prevent binding unless a scriptblock is used?

Viewing 5 reply threads
  • Author
    Posts
    • #238727
      Participant
      Topics: 6
      Replies: 15
      Points: 141
      Rank: Participant

      I want to be able to pipe from Function A to Function B, but I only want Function B to bind to properties if the parameter is named or is named and a script block is used when calling the function. The effect would be that only parameters that are explicitly called bind, even if present on the object passed by Function A.

      • This topic was modified 2 months, 3 weeks ago by Phatmandrake.
      • This topic was modified 2 months, 3 weeks ago by Phatmandrake.
    • #238736
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,686
      Helping Hand
      Rank: Community Hero

      Can you give an example?

    • #238742
      Participant
      Topics: 6
      Replies: 15
      Points: 141
      Rank: Participant

      Would there be a way to prevent the parameter binding from happening on param2 and param3? It inherently binds, is there a way to prevent it?

      • This reply was modified 2 months, 2 weeks ago by Phatmandrake.
      • This reply was modified 2 months, 2 weeks ago by Phatmandrake.
    • #238745
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,686
      Helping Hand
      Rank: Community Hero

      I get the error: Missing an argument for parameter ‘Param1’.

    • #238961
      Participant
      Topics: 6
      Replies: 15
      Points: 141
      Rank: Participant

      Just supply a value to Param1, it will output as indicated. Is there a way to prevent parameter binding is the nature of the question though.

    • #238976
      js
      Participant
      Topics: 32
      Replies: 842
      Points: 2,686
      Helping Hand
      Rank: Community Hero

      That’s sort of like saying, “how can I ignore the parameters that I’m sending?” Why would you want to? You could use select-object to only send the one property.

      • This reply was modified 2 months, 2 weeks ago by js.
      • This reply was modified 2 months, 2 weeks ago by js.
      • This reply was modified 2 months, 2 weeks ago by js.
Viewing 5 reply threads
  • You must be logged in to reply to this topic.