תשובה Powershell syntax for linking workitems

  • יום חמישי 08 מרץ 2012 17:11
     
     

    I'm writting a powershell script to link work items together. I've got the C# code, but I'm just not sure how to covert it to powershell.

    C#: WorkItemLinkType linkType = store.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Hierarchy];

    Powershell: $linkType = $store.WorkItemLinkTypes[CoreLinkTypeReferenceNames.Hierarchy] 

    C#: workItem.Links.Add(new WorkItemLink(linkType.ReverseEnd, workitemID));

    Powershell: $workItem.Links.Add(WorkItemLink(linkType.ReversEnd, $workitemID))

    Thanks,

    Anthony

כל התגובות

  • יום שישי 09 מרץ 2012 03:30
    מנחה דיון
     
     

    Hi Anthony, 

    Thanks for your post.

    If you want to link work items programmatically, we usually suggest you create/add work item links using TFS API, according your description, you have already know how to achieve that using TFS API.

    I’m not the PowerShell expert, but I think you can get some helpful information in this article: http://www.peterprovost.org/blog/post/Fun-with-PowerShell-and-TFS-Work-Items.aspx.

     

    How to covert the API(C#) code to PowerShell script, I suggest you can contact PowerShell expert for the better response.  


    John Qiao [MSFT]
    MSDN Community Support | Feedback to us

  • יום חמישי 03 מאי 2012 19:53
     
     תשובה

    $linkType = $store.WorkItemLinkTypes[[Microsoft.TeamFoundation.WorkItemTracking.Client.CoreLinkTypeReferenceNames]::Hierarchy]
    $link = new-object Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemLink($linkType.ReverseEnd, $workitemID)
    $workItem.Links.Add($link)

    • הוצע כתשובה על-ידי Noah Coad יום חמישי 03 מאי 2012 19:53
    • סומן כתשובה על-ידי Anthony Hunter יום שישי 04 מאי 2012 14:28
    •