Created
September 11, 2018 06:19
-
-
Save raghuacc/cbd8548b1b7d455a5a59e4f3d4dfc8bf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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