Skip to content

Instantly share code, notes, and snippets.

@raghuacc
Created September 11, 2018 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save raghuacc/cbd8548b1b7d455a5a59e4f3d4dfc8bf to your computer and use it in GitHub Desktop.
Save raghuacc/cbd8548b1b7d455a5a59e4f3d4dfc8bf to your computer and use it in GitHub Desktop.
function Get-DA8Stats
{
[cmdletbinding()]
param
(
[parameter(mandatory=$True, ValueFromPipeline=$true, HelpMessage="Computer name or IP address")]
[ValidateCount(1,40)]
[ValidateNotNullOrEmpty()]
[string[]]$ComputerName
)
begin
{}
process
{
foreach ($computer in $ComputerName)
{
$memorysize = [math]::round((Get-WmiObject -ClassName Win32_OperatingSystem -ComputerName $computer).TotalVisibleMemorySize / 1mb)
$numberofprocessors = Get-WmiObject -ClassName Win32_computersystem -ComputerName $computer | select-object NumberOfLogicalProcessors
$daconnections = Get-RemoteAccessConnectionStatisticsSummary -ComputerName $computer | Select-Object totaldaconnections
$proc = Get-WmiObject -computername $computer win32_processor | Measure-Object -property LoadPercentage -Average | Select-Object Average
$mem = gwmi -Class win32_operatingsystem -computername $computer | Select-Object @{Name = "MemoryUsage"; Expression = {“{0:N2}” -f ((($_.TotalVisibleMemorySize - $_.FreePhysicalMemory)*100)/ $_.TotalVisibleMemorySize) }}
$paras = @{"RAM(GB)" = $memorysize;
"No.Of Processors" = $numberofprocessors.numberoflogicalprocessors;
"ComputerName" = $computer;
"Connections" = $daconnections.totaldaconnections;
"Memory %" = $mem.memoryusage;
"CPU %" = $proc.average
}
$obj = New-Object -TypeName psobject -Property $paras
$obj.psobject.typenames.insert(0, "DA.SystemInfo")
Write-Output $obj
}
}
end {}
}
$CurrentDate = Get-Date
$CurrentDate = $CurrentDate.ToString('MM-dd-yyyy_hh-mm-ss')
Update-FormatData -PrependPath C:\scripts\DATest.format.ps1xml
Get-DA8Stats -ComputerName (Get-Content -Path C:\test\servers.txt) | Export-Csv -NoTypeInformation -Path "C:\DA8Data_$CurrentDate.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment