PowerShell script exchange
Post Reply
vitalii.fesh
Influencer
Posts: 12
Liked: 4 times
Joined: May 29, 2024 2:47 pm
Full Name: Vitalii Feshchenko
Contact:

Retrieving the RAM and CPU of proxy servers using PowerShell

Post by vitalii.fesh » 1 person likes this post

Hi, community,

I want to know if there is a method to retrieve RAM, CPU resources of the proxy servers using PS.
albertwt
Veteran
Posts: 945
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Retrieving the RAM and CPU of proxy servers using PowerShell

Post by albertwt » 1 person likes this post

Hi Vitalii,

Do you mean something like this result?

Code: Select all

function Get-RemoteSystemInfo {
    param (
        [string]$computerName
    )

    # Get the number of CPU cores
    $cpuCores = (Get-WmiObject Win32_Processor -ComputerName $computerName).NumberOfCores

    # Get the total physical memory
    $totalMemory = (Get-WmiObject Win32_PhysicalMemory -ComputerName $computerName |
                    Measure-Object -Property capacity -Sum).Sum / 1GB # Convert to GB

    $systemInfo = [PSCustomObject]@{
        ComputerName = $computerName
        CPUCores     = $cpuCores
        TotalMemoryGB= [math]::Round($totalMemory, 2)
    }

    return $systemInfo
}

function Get-ProxyNames {
    # Get a list of VMware backup proxies
    $proxies = Get-VBRViProxy | Select-Object -ExpandProperty Name
    $proxyNames = @($proxies.Name)
    return $proxyNames
}

# Example usage:
$computerNames = Get-ProxyNames
$systemInfoArray = foreach ($name in $computerNames) {
    Get-RemoteSystemInfo -computerName $name
} | Format-Table -AutoSize
--
/* Veeam software enthusiast user & supporter ! */
oleg.feoktistov
Veeam Software
Posts: 2015
Liked: 671 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Retrieving the RAM and CPU of proxy servers using PowerShell

Post by oleg.feoktistov » 2 people like this post

Hi,

There is an alternative way that doesn't involve querying WMI on a remote machine:

Code: Select all

$proxies = Get-VBRViProxy 
foreach ($proxy in $proxies) {
  $physHost = $proxy.Host.GetPhysicalHost()
  $proxy | select Name, @{n='HostName';e={$_.Host.Name}}, @{n='CPUCores';e={$physHost.Hardwareinfo.CoresCount}}, `
  @{n='RAMInGB';e={[Math]::Round($physHost.HardwareInfo.PhysicalRAMTotal/1GB, 2)}}
}
We write server hardware info to VBR DB, so we can obtain it directly.

Best regards,
Oleg
albertwt
Veteran
Posts: 945
Liked: 53 times
Joined: Nov 05, 2009 12:24 pm
Location: Sydney, NSW
Contact:

Re: Retrieving the RAM and CPU of proxy servers using PowerShell

Post by albertwt »

That's great, thank you @Oleg.
--
/* Veeam software enthusiast user & supporter ! */
vitalii.fesh
Influencer
Posts: 12
Liked: 4 times
Joined: May 29, 2024 2:47 pm
Full Name: Vitalii Feshchenko
Contact:

Re: Retrieving the RAM and CPU of proxy servers using PowerShell

Post by vitalii.fesh »

Thanks @albertwt and @oleg.feoktistov
That is really what I wanted to know.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests