2

The powershell code below returns a list of Changesets. I would like to loop through each changeset so that I can access the properties.

$items = Get-TfsItemHistory $tfsProject -Version "D$lastChangeDateTime~" -Recurse -Server $tfs -IncludeItems

For example

foreach($item in $items)

{

    Write-Host $item.ServerItem
}

I believe the ServerItem property holds the path to the changed file on the server. There are other properties I would like to access. Any help on this would be appreciated. The purpose of this is to deploy the files associated in each changeset. I will be copying them over to the server and will need access to other properties for notifications, comments and other things.

ScottJShea
  • 7,041
  • 11
  • 44
  • 67
Akin
  • 137
  • 2
  • 12

2 Answers2

1

try in the foreach

$Item | get-member 

or simply

$items[0] | get-member # if is an array

to retrieve a list of properties and methods available in the object.

CB.
  • 58,865
  • 9
  • 159
  • 159
  • Hey Christian, Thanks for the response. The get-member returned a list showing different methods/properties and an explanation of the membertype. It didnt give any of the values on the item. – Akin Apr 02 '12 at 19:11
  • Sure! A list of properties and/or method of your object $item. After you know the properties you can use it in your script. – CB. Apr 02 '12 at 19:14
  • Ok, thanks Christian, I see what you are getting at now. I do have another question if thats fine with you. if i were to Write $items array to the console, I see a Serveritem property. I dont think I can access that property using any of the properties exposed by the Get-Member. I do see this property again when I do $item.Changes. How can I access this? Do I do something like $item.Changes.Serveritem? – Akin Apr 02 '12 at 19:26
  • I'm sorry but I can't help more... Never used Get-TfsItemHistory. Using get-member you can see in the rigth column il property have get and/or set method. If there's is only get is a read only property and you can change this value. – CB. Apr 02 '12 at 19:34
  • I found out the ChangeType property resides on the ChangeSet.Changes object, and Serveritem, and itemtype reside on the ChangeSet.Changes.Item property. This is the level where the file can also be downloaded. Thanks for showing me the get-member object. It helped me figure this out... – Akin Apr 02 '12 at 21:27
0

Try : Get Latest Version of Folder from TFS, using Powershell

Gets the latest of the particular folder you are looking for, and not the entire root of TFS.

Community
  • 1
  • 1
ArNumb
  • 307
  • 1
  • 4
  • 10