New-VSTeamWorkItemRelation -RelationType Duplicate -Id 55 -Comment "My comment"
ID RelationType Operation Index Comment
-- ------------ --------- ----- -------
55 System.LinkTypes.Hierarchy-Reverse add - My commentSimple invocation, returns a Relation object.
$relations = New-VSTeamWorkItemRelation -Operation Remove -Index 0 |
New-VSTeamWorkItemRelation -Operation Remove -Index 1
Update-VSTeamWorkItem -Id 30 -Relations $relationsRemoves work first 2 links from work item 30
$relations =@()
$relations += New-VSTeamWorkItemRelation -Operation Remove -Index 0
$relations += New-VSTeamWorkItemRelation -RelationType Related -Id 66
Update-VSTeamWorkItem -Id 30 -Relations $relationsSimilar to example 2, but managing the relations collection directly Pay attention that the first relation, for Operation Remove, only the Index parameter is provided. In the second relation, when provided the Id, it's necessary to provide the RealationType. The operation will be always Add.
$relations = 55,66 | New-VSTeamWorkItemRelation -RelationType Child
Update-VSTeamWorkItem -Id 30 -Relations $relations
Adds work items 55 and 56 as children of 30 Pay attention that this use case, passing a list of IDs from pipeline, has sense only for 'Add' operation, and because this is the defaut operation value, we can ommit the Operation parameter
$relations = Get-VSTeamWorkItem -Id 55 | New-VSTeamWorkItemRelation -RelationType Duplicate -Comment "is it dupllicate?"
Update-VSTeamWorkItem -Id 30 -Relations $relations
Adds work items 55 as duplicate of 30 Pay attention that this use case, passing a list of work items from pipeline, has sense only for 'Add' operation, and because this is the defaut operation value and the Operation parameter is not allowed when you provide the Id
$relations = Get-VSTeamWiql -Id "f87b028b-0528-47d6-b517-2d82af680295" |
Select-Object -ExpandProperty WorkItems |
New-VSTeamWorkItemRelation -RelationType Related
Update-VSTeamWorkItem -Id 30 -Relations $relationsAdds all work items returned by a query as related to work item 30 Pay attention that this use case, passing a list of work items from pipeline, has sense only for 'Add' operation, and because this is the defaut operation value, we can ommit the Operation parameter
$relation = New-VSTeamWorkItemRelation -RelationType Related -Operation Replace -Comment "updated comment"
Update-VSTeamWorkItem -Id 30 -Relations $relationsUpdates the comment of a relation. The replace operation only supports comment update. If you really need to change a relation, like re-parent a work item, you need to create two relations: first, remove and then add operations.
$relations =@()
$id = Get-VSTeamWorkItem -id 30 -Expand Relation
for ($i=0; $i -lt $id.relations.Count; $i++) {
$relations += New-VSTeamWorkItemRelation -Operation Remove -Index $i
}
Update-VSTeamWorkItem -Id 30 -Relations $relationsRemoves all the links from work item 30
Operation: Intended for fluent syntax (see Example 2)
Type: PSCustomObject[]
Parameter Sets: ByObject
Required: True
Accept pipeline input: trueRelated WorkItem id
This is not the work item to be updated, but the work item that will be part of the relations of the updated work item Can be used as parameter or pass a list of ID's or a list of work items from the pipeline
Type: int[]
Parameter Sets: ByID,ByObject
Required: True
Accept pipeline input: trueSpecify the relation type. The relation name is translated to the technical name. You can tab complete from a list of available relation types. Also you can get a list of relation types using the Get-VSTeamWorkItemRelationType CmdLet Not allowed when you specify an index in the remove or replace operations
Type: String
Parameter Sets: ByID,ByRelation
Required: True (in ByID parameterset)Remove or Replace a relation The Add operation is implicit when the Id parameter is used. So this parameter is only valid when Index is specified
Type: string
Parameter Sets: ByIndex,ByRelation
Required: False
Accepted values: Remove, ReplaceAdd (or edit -with Replace operation-) a comment to the relation
Type: string
Required: FalseThis CmdLet do not modify any work item, just generates a JSON Patch compatible object that describes the updates to be applied using the Update-VSTeamWorkItem
Get-VSTeamWorkItemRelationType Get-VSTeamWorkItem Update-VSTeamWorkItem