Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Copy Entire Files From TFS To Local Using PowerShell
WhatsApp
Dorababu Meka
Jul 22
2016
7.1
k
0
1
C
cls
Write-Host
"Enter source location "
$sourceLocation
= Read-Host
$tfsCollectionUrl
= New-Object System.URI(
$sourceLocation
);
Write-Host
"Enter server path "
$serverPath
= Read-Host
Write-Host
"Enter local path to download"
$localPath
= Read-Host
[Microsoft.TeamFoundation.Client.TfsTeamProjectCollection]
$tfsCollection
= Get-TfsServer
$tfsCollectionUrl
$VersionControl
=
$tfsCollection
.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
$latest
= [Microsoft.TeamFoundation.VersionControl.Client.VersionSpec]::Latest
$recursionType
= [Microsoft.TeamFoundation.VersionControl.Client.RecursionType]::Full
try
{
foreach
(
$item
in
$VersionControl
.GetItems(
$serverPath
,
$latest
,
$recursionType
).Items)
{
$target
= [io.path]::Combine(
$localPath
,
$item
.ServerItem.Substring(2))
$exists
=[System.IO.Directory]::Exists(
$target
)
if
(
$item
.ItemType -eq
"Folder"
-
and
!
$exists
)
{
New-Item
$target
-Type Directory
}
if
(
$item
.ItemType -eq
"File"
)
{
$item
.DownloadFile(
$target
)
}
}
Write-Host
"`n Successfully downloaded all the files to the target folder: "
$localPath
-ForegroundColor Green
}
catch
{
$ErrorMessage
=
$_
.Exception.Message
$FailedItem
=
$_
.Exception.ItemName
Break
}
PowerShell
TFS
Copy Entire Files
Up Next
Copy Entire Files From TFS To Local Using PowerShell