locked
Getting SQL Server Memory Stats with Powershell RRS feed

  • Question

  • Hello Forum

    I'm creating a script to grab some memory and pagefile information, running through an array of Servers.

    I'm struggling with the Memory used be all SQL Processes and the amount of PageFile used be all SQL Processes

    For Memory I've so far got this

    $MemoryUsedBySQLProcess=Get-ProcessSQLSERVR|Select-ObjectNPM

    For PageFile I've got this: -

    $MemoryUsedBySQLProcess=Get-ProcessSQLSERVR|Select-ObjectNPM

    I've tried adding

    -computername$server

    to these commands (@server being the Machine name from the array)  But neither are working, can anyone please help


    Please click "Mark As Answer" if my post helped. Tony C.

    Friday, June 16, 2017 3:17 PM

Answers

  • Why do you make so many calls?

    get-process sql* -ComputerName alpha | 
         select MachineName,PrivateMemorySize,PagedMemorySize,VirtualMemorySize
    Please post code correctly.  DO not post colorized code as it is unusable and unreadable.


    \_(ツ)_/

    • Proposed as answer by Hello_2018 Monday, June 19, 2017 8:06 AM
    • Marked as answer by Anthony C-UK Tuesday, June 20, 2017 8:53 AM
    Friday, June 16, 2017 3:28 PM

All replies

  • Why do you make so many calls?

    get-process sql* -ComputerName alpha | 
         select MachineName,PrivateMemorySize,PagedMemorySize,VirtualMemorySize
    Please post code correctly.  DO not post colorized code as it is unusable and unreadable.


    \_(ツ)_/

    • Proposed as answer by Hello_2018 Monday, June 19, 2017 8:06 AM
    • Marked as answer by Anthony C-UK Tuesday, June 20, 2017 8:53 AM
    Friday, June 16, 2017 3:28 PM
  • Hi,

    >>I'm creating a script to grab some memory and pagefile information, running through an array of Servers.

    To make the script more graceful:

    $computers = @('server1','server2','...')
    foreach($ser in $computers)
    {
        Invoke-Command -ComputerName $ser -ScriptBlock{gps | select MachineName,PrivateMemorySize,PagedMemorySize,VirtualMemorySize} -Credential(Get-Credential)
    }
    

    Besides, did you have any updates?

    Best regards,

    Andy


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, June 19, 2017 8:06 AM