We monitor our computer performance daily like capturing CPU and Memory Utilization on Remote Computers, there is a performance issue on multiple remote computers the script in this article is really useful to troubleshoot the issue.
Windows administrators often run into performance issues on desktops and servers machines, sometimes it is very difficult to log in to multiple computers and check the utilization of CPU and Memory.
End users report performance issues every day, if there is a script available to check the CPU and Memory utilization on the remote computers then it helps IT help desk people a lot, this article explains how a Powershell script pulls the performance report of remote computers and saves the report details in CSV file.
Based on this CSV report the IT help desk people get can take the required action or investigate the performance issue and identify the root cause of the issue.
We need to create a text file for remote computers list that we are going to check CPU and Memory utilization, here I have created a text file named as allservers.txt and saved it in location C\temp\allservers.txt
$Allservers = Get-Content "C:\temp\Allservers.txt" $Output = @() ForEach ($Server in $Allservers) { $Processor = $null $Memory = $null $RoundMemory = $null $Object = $null $Server = $Server.trim() Try { # Processor Check $Processor = (Get-WmiObject -ComputerName $Server -Class win32_processor -ErrorAction Stop | Measure-Object -Property LoadPercentage -Average | Select-Object Average).Average # Memory Check $Memory = Get-WmiObject -ComputerName $Server -Class win32_operatingsystem -ErrorAction Stop $Memory = ((($Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory)*100)/ $Memory.TotalVisibleMemorySize) $RoundMemory = [math]::Round($Memory, 2) $Object = New-Object PSCustomObject $Object | Add-Member -MemberType NoteProperty -Name "Server name" -Value $Server $Object | Add-Member -MemberType NoteProperty -Name "CPU %" -Value $Processor $Object | Add-Member -MemberType NoteProperty -Name "Memory %" -Value $RoundMemory $Object $Output += $Object } Catch { Write-Host "There are errors ($Server): "$_.Exception.Message Continue } } #Exporting the result to an excel CSV file. If ($Output) { $Output | Export-Csv -Path "C:\temp\ouput.csv" -NoTypeInformation -Force }
When you run this script the output of the CPU and Memory Utilization report will be stored in the location C:\temp\output.csv, make sure you have all privileges to run this script on the remote computer.
One can also modify this script and check the local computer CPU and Memory utilization.
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply