简体   繁体   English

Powershell获取有关工作文件夹的最新信息?

[英]Powershell get latest on a working folder?

I am trying to get latest on a specific folder and was wondering how I would do this. 我正在尝试获取特定文件夹的最新信息,并且想知道我该怎么做。 I have been reading the MSDN documentation about the Workspace class but unfortunately it doesn't seem to provide any information about how I would go about getting latest of a specific folder. 我一直在阅读有关Workspace类的MSDN文档,但是不幸的是,它似乎没有提供有关如何获取特定文件夹的最新信息。

For example, I have a single workspace but with multiple working folders. 例如,我只有一个工作区,但有多个工作文件夹。 My PowerShell script can get latest but only at workspace level. 我的PowerShell脚本可以获取最新信息,但只能在工作空间级别获取。 Is it possible to get it from a working directory level or at a particular folder level? 是否可以从工作目录级别或特定文件夹级别获取它?

Thanks in advance, DS. 预先感谢DS。

EDIT I believe this is possible as power tools is able to do it via right clicking a folder and getting latest. 编辑我相信这是可能的,因为电动工具可以通过右键单击文件夹并获取最新信息来做到这一点。 Ideally, want to replicate this. 理想情况下,要复制此内容。

http://msdn.microsoft.com/en-us/library/Microsoft.TeamFoundation.VersionControl.Client.Workspace.aspx http://msdn.microsoft.com/en-us/library/Microsoft.TeamFoundation.VersionControl.Client.Workspace.aspx

The below shows my script in practice.. 下面显示了我的实践脚本。

$tfs = .\tfs-get-instance.ps1 -uri $uri
$vcs = $tfs.TfsTeamProjectCollection.GetService([Microsoft.TeamFoundation.VersionControl.Client.VersionControlServer])
[psobject]$workspace = $vcs.GetWorkspace([System.Environment]::MachineName, [System.Environment]::UserName)
$workspace.Map($sourceFolder, $localFolder)
$result = $workspace.GetLocalItemForServerItem($sourceFolder);

if ($result -ne "")
{
    echo $result
}

You should be able to use the Workspace.Get Method (String[], VersionSpec, RecursionType, GetOptions) to get what you want. 您应该可以使用Workspace.Get方法(String [],VersionSpec,RecursionType,GetOptions)来获取所需的内容。

On the other hand, if you don't necessarily want to do it using the .NET objects, you could let tf.exe do the actual work, like the following: 另一方面,如果您不一定要使用.NET对象,可以让tf.exe完成实际工作,如下所示:

& $TfExePath workfold /map "$codePath" "$LocalFolderPath" /collection:"$tfCollection" /workspace:$workspaceName
& $TfExePath get "$codePath" /version:$ChangeSet /force /overwrite /all /recursive $workspaceName

On the other hand, if you have the TF PowerTools installed you should also have PowerShell cmdlets for working with TFS. 另一方面,如果安装了TF PowerTools,则还应该具有用于​​处理TFS的PowerShell cmdlet。 I have never used them, but I'm guessing you should be able to use them instead of using tf.exe if you want to. 我从未使用过它们,但是我想您应该可以使用它们,而不是使用tf.exe。 I would probably go for the PowerShell cmdlets in the power tools if they fill your need. 如果满足您的需求,我可能会在电动工具中使用PowerShell cmdlet。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM