tags:

views:

128

answers:

2

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..

A: 

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
A: 

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.

Filburt
Get-TfsItemProperty $/MyFirstTFSProj -r -server xyzc011b| Where {$_.CheckinDate -gt (Get-Date).AddDays(-30)} | Copy-Item -Path $_.LocalItem -Destination C:\SomeDir -Whatif
barry
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