2012-08-05 31 views
0

我想将我的工具移动到powershell,this可以在PowerShell中完成吗?我真正感兴趣的位为:通过powershell获取所有tfs警报订阅的列表(通过powershell获得.Net程序集?)

IEventService es = tfs.GetService(typeof(IEventService)) as IEventService; 
List<Subscription> ls = es.GetAllEventSubscriptions().ToList(); 

欢呼

编辑:我真正想做的事情可能会使用来自PowerShell中的.NET程序集,然后这可能是Using .NET library from PowerShell

重复

回答

1

下面是PowerShell函数中的一个TFS API,我很早以前就在博客中发现了这个函数,可以帮助您入门。我已经将它发布到GitHub Gist上。基本上你确保你已经装载了TFS组件到AppDomain中,然后你可以添加任何TFS服务接口要的对象,他们就像你在任何C#应用程序只是操作等

https://gist.github.com/3288447

一旦你的TFS对象从方法返回的要义上面,你可以像这样在加载服务工作:

#use work item service 
$tfs = get-tfs $env:TFSSERVERURL -silent 
$project = $tfs.wit.Projects | ?{ $_.Name -eq $projectName} 
#todo - replace with text for query or file read -- this is deprecated 
$query = $project.StoredQueries | ?{ $_.Name -eq 'Active Bugs' } 
$queryText = $query.QueryText.Replace("@project","'$projectName'") 

$results = $tfs.wit.Query($queryText) 
#do something with the results... 

在您的要求上面你可以改变一开始TFS方法添加你的服务接口加载到集合上,然后在.NET方法上运行,就像我在例子中做的那样在上面。

+0

谢谢,我会试试看 – timB33 2012-08-08 07:12:58