-3

this is the scenario.

p1

 |_f1

 |_f2



p2

  |_f1

  |_f2

Can anyone please help me with a powershell script that copies the files shown above from the TFS to a temporary folder ??? where f1,f2,and so on are the subfolders..

Joey
  • 344,408
  • 85
  • 689
  • 683
barry
  • 43
  • 1
  • 4
  • 5
    I imagine this question won't get a very warm reception here...people on this site tend to like to see that you've put some effort it to an attempt. You'll probably have more luck either 1) asking for a good place to start (i.e. a website or book) or 2) doing some googling to get a start and then asking any questions you have along the way on this site. I could be totally wrong and somebody might help you, but that's just what I've seen in the past. – Chris Thompson Apr 28 '10 at 06:14
  • 3
    I don't even get what they are trying to do here. – Joey Apr 28 '10 at 07:44
  • 1
    Does anyone have a handy powershell script that gets a set of files from TFS based on a modification date? I'd like to say "give me all the files in this folder (or subfolder) that were modified after X/Y/ZZZZ" and dump those files to a folder other than the folder they would normally go to... I am totally new at scripting and i need some guidance. – barry Apr 28 '10 at 08:29

2 Answers2

1

I have no experience with either, but in the interest of a least pointing you in the right direction, check out this site. http://coolthingoftheday.blogspot.com/2009/03/pstfs-powershell-and-tfs-better-than.html

There are a couple of commands that will give you at least part of what you want. You will still need to do some digging to figure out the time stamp stuff.

Chris Thompson
  • 35,167
  • 12
  • 80
  • 109
1

You may want to check the answer to my question on a very similar scenario.

You will find answer to

give me all files in this folder (or subfolder)

as well as

that where modified after x/y/zzzz

but I'm still not sure about the

dump those files to folder other than they would normally go to


update

Incorporating your approach

Get-TfsItemProperty $/MyFirstTFSProj -r -server xyzc011b | 
Where {$_.CheckinDate -gt (Get-Date).AddDays(-30)} | 
Copy-Item -Destination C:\SomeDir -Whatif

you normally can omit the Copy-Item -Path param because it will be provided by the pipeline.

I don't have a TFS at to test with Get-TfsItemProperty but you could try

Get-TfsItemProperty $/MyFirstTFSProj -r -server xyzc011b | 
Where {$_.CheckinDate -gt (Get-Date).AddDays(-30)} | 
Get-Member

do find out about where this $null value is coming from.

I assume you did already see this post. To maintain the folder structure on the destination you need to include the -Force switch on the Copy-Item to create missing target folders:

Get-TfsItemProperty $/MyFirstTFSProj -r -server xyzc011b | 
Where {$_.CheckinDate -gt (Get-Date).AddDays(-30)} | 
Copy-Item -Destination C:\SomeDir -Force -Whatif

I'm still not sure if you need to retrieve/export the files prior to copy them - you should check on the second answer from Richard Berg in the post mentiond above.

Community
  • 1
  • 1
Filburt
  • 17,626
  • 12
  • 64
  • 115
  • Get-TfsItemProperty $/MyFirstTFSProj -r -server xyzc011b| Where {$_.CheckinDate -gt (Get-Date).AddDays(-30)} | Copy-Item -Path $_.LocalItem -Destination C:\SomeDir -Whatif – barry Apr 29 '10 at 06:36
  • but the above code is showing an error as..... Copy-Item : Cannot bind argument to parameter 'Path' because it is null. At line:2 char:20 + Copy-Item -Path <<<< $_.LocalItem -Destination C:\SomeDir -Whatif – barry Apr 29 '10 at 06:37