This PowerShell script is used to get SQL Server buffer pool usage. It will demonstrate how to get the following information:
• System memory usage
• Memory usage of the SQL Server process
• Total buffer usage of databases
• The count of pages loaded for each object in the current database
As some people want to know what the memory resource is used for, we provide this script to show which objects are consuming the memory or buffer pool.
You can use this script in this way:
1. Run Microsoft PowerShell as Administrator
2. Run the script in the form: Path or &"Path"
For example: E:\GetBufferPoolUsage.ps1
3. Press "Enter" and enter the parameters: the name of the server and the database you want to connect to.
After the script finishes running, we'll get the following figure:
Here are some code snippets for your reference.
Windows PowerShell 2.0 and higher version
Microsoft All-In-One Script Framework is an automation script sample library for IT Professionals. The key value that All-In-One Script Framework is trying to deliver is Scenario-Focused Script Samples driven by IT Pros' real-world pains and needs. The team is monitoring all TechNet forums, IT Pros' support calls to Microsoft, and script requests submitted to TechNet Script Repository. We collect frequently asked IT scenarios, and create script samples to automate the tasks and save some time for IT Pros. The team of All-In-One Script Framework sincerely hope that these customer-driven automation script samples can help our IT community in this script-centric move.