Link to home
Start Free TrialLog in
Avatar of whorsfall
whorsfallFlag for Australia

asked on

Powershell monitoring SQL Transaction logs.

Hi,

I am looking for some powershell code that will allow me
to

1) Get the Size of a SQL transaction log.
2) Get the percentage used of a transaction log.
3) Get the current used space within the transaction log.

Thanks,

Ward
Avatar of lcohan
lcohan
Flag of Canada image

Why do you need to do that in PowerShell?

SQL has one statement that givew you all that info - just run


for SQL 2000: http://msdn.microsoft.com/en-us/library/aa258819(v=sql.80).aspx

DBCC SQLPERF ( LOGSPACE )

for SQL 2005 and up: http://msdn.microsoft.com/en-us/library/ms189768.aspx

DBCC SQLPERF
(
     [ LOGSPACE ]
     |
          [ "sys.dm_os_latch_stats" , CLEAR ]
     |
     [ "sys.dm_os_wait_stats" , CLEAR ]
)
     [WITH NO_INFOMSGS ]
Avatar of whorsfall

ASKER

Hi.

Because we want to monitor multiple servers and sql databases at once.

So just something that scales a bit better.

Thanks,

Ward
ASKER CERTIFIED SOLUTION
Avatar of lcohan
lcohan
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial