简体   繁体   English

如何使用 PowerShell 监控 VSTS 代理的可用性?

[英]How to monitor VSTS agent availability using PowerShell?

How to get vsts agent status from a remote agent machine using powershell?如何使用powershell从远程代理机器获取vsts代理状态? I did google search and i didn't find any ideas or information about this.我做了谷歌搜索,我没有找到任何关于这个的想法或信息。

I found solution in c#.我在 c# 中找到了解决方案。 But i am unable to do this in powershell.但是我无法在 powershell 中执行此操作。 I tried to call the c# code in powershell.我试图在 powershell 中调用 c# 代码。 I am getting the error我收到错误

Add-Type : (0) : Metadata file 'Microsoft.TeamFoundation.Client, Version=15.0.0.0.dll' could not be found (1) : using Microsoft.TeamFoundation.Client;添加类型:(0):找不到元数据文件“Microsoft.TeamFoundation.Client,版本=15.0.0.0.dll”(1):使用 Microsoft.TeamFoundation.Client;

My code that is throwing the error is我抛出错误的代码是

$Assemblies = ("Microsoft.TeamFoundation.Client, Version=15.0.0.0", "Microsoft.TeamFoundation.Lab.Client, Version=15.0.0.0") $Assemblies = ("Microsoft.TeamFoundation.Client, Version=15.0.0.0", "Microsoft.TeamFoundation.Lab.Client, Version=15.0.0.0")

You need to reference your .dll file by path:您需要通过路径引用您的.dll文件:

Add-Type -Path 'C:\path\to\your\assembly.dll'

Keep in mind that as -Path accepts array of strings ( see the docs ) you can use it like this:请记住,由于-Path接受字符串数组( 请参阅文档),您可以像这样使用它:

$assemblies = "C:\Path\To\Microsoft.TeamFoundation.Client.dll", "C:\Path\To\Microsoft.TeamFoundation.Lab.Client.dll"
Add-Type -Path $assemblies 

Edit: as it's been spotted (in the comments - credits to user3081672 ), alternative method is to run编辑:因为它被发现(在评论中 - 归功于user3081672 ),替代方法是运行

TestControllerConfig.exe status

This will give you status of all the agents on the controller.这将为您提供控制器上所有代理的状态。 Check example here . 在此处查看示例。

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

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