Skip to content

Commit 4423e39

Browse files
added Get-DBADatabaseSize and Get-DBAErrorLogPath
1 parent 66cea73 commit 4423e39

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

Get-DBADatabaseSize.ps1

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
.EXAMPLE
1313
Get-DBADatabaseSize -Instance SERVER -Top 3
1414
15+
Returns the database names and sizes in Mb ordered by size for the 3 largest databases on SERVER
16+
.EXAMPLE
17+
Get-DBADatabaseSize SERVER 3
18+
1519
Returns the database names and sizes in Mb ordered by size for the 3 largest databases on SERVER
1620
.OUTPUTS
1721
Database object

Get-DBAErrorLogPath.ps1

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
function Get-DBAErrorLogPath
2+
{
3+
<#
4+
.Synopsis
5+
Returns the Error Log PAths for a SQL Server
6+
.DESCRIPTION
7+
returns the SQL or Agent Error log paths for a SQL Server
8+
.EXAMPLE
9+
Get-DBAErrorLogPath -Instance SERVER
10+
11+
Returns the Error Log Path for a SQL Server
12+
.EXAMPLE
13+
Get-DBADatabaseSize -Instance SERVER -Agent
14+
15+
Returns the SQL and Agent Log Error Paths for the SERVER
16+
.EXAMPLE
17+
Get-DBADatabaseSize SERVER
18+
19+
Returns the Error Log Path for a SQL Server
20+
.OUTPUTS
21+
String
22+
.NOTES
23+
AUTHOR - Rob Sewell https://sqldbawithabeard.com
24+
DATE - 11/11/2016
25+
#>
26+
#Requires -Version 5
27+
[OutputType([string])]
28+
param(
29+
## The Name of the instance
30+
[Parameter(Position=0,Mandatory=$true)]
31+
[string]$Instance,
32+
## Display the AgentLog path as well
33+
[switch]$Agent
34+
)
35+
[void][reflection.assembly]::LoadWithPartialName( "Microsoft.SqlServer.Smo" );
36+
$srv = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Server -ArgumentList $Instance
37+
Write-Output "Error Log Path - $($srv.ErrorLogPath)"
38+
if($Agent)
39+
{
40+
Write-Output "Agent Error Log Path - $($srv.JobServer.ErrorLogFile)"
41+
}
42+
}

0 commit comments

Comments
 (0)