0
Я пытаюсь получить вывод, содержащий все подключения к моему PVS-серверу. Я использую PowerShell, чтобы достичь его и сделал следующее:Попытка получить информацию о соединениях с сервером PVS
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 :
Как изменить свой код, чтобы он работает успешно?