0

qfarm /loadI have a problem with remote executing a script.

The script invokes a command for cmd qfarm /load and converts the result to PSObjects.

function New-qLast()
{
    param ([String] $qName, [String] $qLoad)
    $qLast = New-Object PSObject

    $qLast | Add-Member -MemberType NoteProperty -Name ServerName -Value $qName
    $qLast | Add-Member -MemberType NoteProperty -Name ServerLast -Value $qLoad

    return $qLast
}

Write-Host "Start" 

$b = @()
foreach ($a in $(qfarm /load))
{
    $b += $a.Split(" ") | Where-Object { $_ -ne "" }
}
$b

$table = @()
for ($i = 5; $i -lt $b.Length; $i += 2) #for XA 4.5 $i = 5 $i += 2; for XA 6.5 $i += 5 and $i = 8
{
    $table += New-qLast $b[$i] $b[$i+1]
}
$table

as soon as it get's to invoking the qfarm /load nothing is happening anymore.

When I execute the script directly on a terminal server it works fine.

I also tried to run Invoke-Command -ComputerName Server01 {qfarm /load} that works for the first 22 servers of the farm then it's not returning anything but still running till you manually turn it off.

Has anyone an idea why it get's stuck?

Thanks in advance.

IronGibbet
  • 45
  • 3
  • 8
  • I'm not familiar with `qfarm /load` what is it, and what does it do? – E.V.I.L. Mar 22 '13 at 02:19
  • It looks like `qfarm /load` returns servername and load, is that right? `qfarm` is a command that was made for CMD so it will return text not an object. So, `$(qfarm /load)` may not work. Do `$test = (qfarm /load); $test.gettype()`. My guess is the it will be an array of strings. – E.V.I.L. Mar 22 '13 at 02:25
  • Try `$data = cmd /c 'qfarm /load'` – E.V.I.L. Mar 22 '13 at 02:29

1 Answers1

0

First of all thanks Bob and sorry for my late reply.

Unfortunately your method doesn't work, but I found a way around.

I found this VBS and used it for my PowerShellscript.

It looks like this:

$server = Import-Csv C:\Server_On.txt | Where-Object { $_.ServerStatus -eq $true }

$load = Get-WmiObject -ComputerName $server.ServerName -Namespace "root\citrix" -Class MetaFrame_Server_LoadLevel | Select-Object Servername, LoadLevel

the only difference to qfarm /load is that you have to address every single server.

IronGibbet
  • 45
  • 3
  • 8