commands

^

Get-DbaMemoryUsage

Author Klaas Vandenberghe (@PowerDBAKlaas)
Availability Windows only

 

Synopsis

Get amount of memory in use by all SQL Server components and instances

Description

Retrieves the amount of memory per performance counter. Default output includes columns Server, counter instance, counter, number of pages, memory in KB, memory in MB SSAS and SSIS are included.

SSRS does not have memory counters, only memory shrinks and memory pressure state.

This function requires local admin role on the targeted computers.

Syntax

Get-DbaMemoryUsage
    [[-ComputerName] <DbaInstanceParameter[]>]
    [[-Credential] <PSCredential>]
    [-EnableException]
    [<CommonParameters>]

 

Examples

 

Example: 1
PS C:\> Get-DbaMemoryUsage -ComputerName sql2017

Returns a custom object displaying Server, counter instance, counter, number of pages, memory

Example: 2
PS C:\> Get-DbaMemoryUsage -ComputerName sql2017\sqlexpress -SqlCredential sqladmin | Where-Object { $_.Memory.Megabyte -gt 100 }

Logs into the sql2017\sqlexpress as sqladmin using SQL Authentication then returns results only where memory exceeds 100 MB

Example: 3
PS C:\> $servers | Get-DbaMemoryUsage | Out-Gridview

Gets results from an array of $servers then diplays them in a gridview.

Optional Parameters

-ComputerName

The Windows Server that you are connecting to. Note that this will return all instances, but Out-GridView makes it easy to filter to specific instances.

Alias Host,cn,Server
Required False
Pipeline true (ByValue)
Default Value $env:COMPUTERNAME
-Credential

Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential). Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory - Integrated are all supported. For MFA support, please use Connect-DbaInstance.

Alias
Required False
Pipeline false
Default Value
-EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message. This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting. Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

Alias
Required False
Pipeline false
Default Value False

 

Want to see the source code for this command? Check out Get-DbaMemoryUsage on GitHub.
Want to see the Bill Of Health for this command? Check out Get-DbaMemoryUsage.