< Back

Get-DbaMemoryUsage

Mon Jan 13, 2020 11:17 am

NAME Get-DbaMemoryUsage



SYNOPSIS

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





SYNTAX

Get-DbaMemoryUsage [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-Credential]

<Pscredential>] [-EnableException <Switch>] [<CommonParameters>]





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.





PARAMETERS

-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Credential [<Pscredential>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: Memory

Author: Klaas Vandenberghe (@PowerDBAKlaas)



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



SSIS Counters: https://msdn.microsoft.com/en-us/library/ms137622.aspx



-------------------------- 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.



RELATED LINKS

https://dbatools.io/Get-DbaMemoryUsage