尝试获取与PVS服务器的连接的详细信息

时间:2016-12-29 10:30:40

标签: powershell citrix

我正在尝试获取输出,以提供与PVS服务器的所有连接。我正在使用powershell来实现它并执行以下操作:

Add-PSSnapIn MCLIpssnapin

#PVS Variables

$pvsservers = "ASPPVS.ASPcloud.com"

$body +=echo "-----------------------------Connections to PVS server-------------------------------"`r`n""`r`n""
foreach ($server in $pvsservers)
    {
    $pvsstatus = Mcli-Get ServerStatus -p servername="$server" | findstr "deviceCount"
    $pvsstatus = $pvsstatus.Replace("deviceCount:","")
    $body +=echo "Current Connections to $server : $pvsstatus

"
    }
Write-Output $body

通过这样做,我收到以下错误:

Mcli-Get : The specified Server does not exist.
At C:\Users\ctxadmin\Desktop\PVS.ps1:10 char:15
+     $pvsstatus = Mcli-Get ServerStatus -p servername="$server" | findstr "deviceCou ...
+                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : DeviceError: (:) [Mcli-Get], EAException
    + FullyQualifiedErrorId : InvalidServer,McliPSSnapIn.McliGet

You cannot call a method on a null-valued expression.
At C:\Users\ctxadmin\Desktop\PVS.ps1:11 char:2
+     $pvsstatus = $pvsstatus.Replace("deviceCount:","")
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

-----------------------------Connections to PVS server-------------------------------



Current Connections to APNPVS02.Apncloud.com :

如何更改代码以使其成功运行?

1 个答案:

答案 0 :(得分:0)

我通过 排除域名 解决了这个问题。 我给出了整个计算机名称: $ pvsservers =“ASPPVS.ASPcloud.com”。 相反,我提供了计算机名称,不包括域名: ASPPVS