I am trying to get an output giving all the connections to my PVS server. I am using powershell to achieve it and did the following :
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
By doing this, I get the following error :
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 :
How do I change my code to get it running successfully?
I solved it by excluding the domain name. I was giving the entire computer name : $pvsservers = "ASPPVS.ASPcloud.com". Instead, I gave the computer name, excluding the domain name as : ASPPVS