0

I have an object that holds numbers $names

name
123
456
789
012
...

I need to compose a title for an item in TFS like: My Title 123 456 789 012 ...

Add-VSTeamWorkItem -Title "My title $names" -Description "This is a description" -WorkItemType Task

If it will be run in a loop many work items will be created What is the right way to do it?

I managed to build the title. Now I need to build the description that contains in each line a title that I get from the TFS. I tried this but its not working because the object holds only one title

foreach ($patch in $patches)
{
    $title = (Get-VSTeamWorkItem -Id $patch.Patch).fields.'system.Title'
}
1
  • 1
    Is "My title $names" not working as expected? Commented Mar 2, 2022 at 18:58

1 Answer 1

1

Your sample data suggests that $names contains an array of objects with a .name property, and that you want to space-concatenate these property values inside an expandable (double-quoted) string ("..."):

"My Title $($names.name)"

If, by contrast, the inclusion of column header name in your sample data is just a formatting artifact, the solution is simpler:

"My Title $names"

When PowerShell stringifies an array, it space-concatenates its stringified elements, so that "$(1, 2)" becomes verbatim 1 2, for instance.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.