Sqlserver-dba.com

Subscribe

SQLServer-DBA.com Links

Subscribe to newsletter

Dba_db2_button

Powered by TypePad
Free disk space on drives using Powershell

01 May,2010 by Jack Vamvas

This script  using Powershell , takes a  list of SQL Servers , iterates through
the list and returns the results from the procedure : master.dbo.xp_fixeddrives.
Run this script as a standalone script or as part of a more comprehensive health monitoring snapshot

Depending on your security architecture , there may be a requirement to adjust the security method used to authenticate on the SQL Server

############START#################

foreach ($svr in get-content "C:\MySQLServers.txt"){
    $dt = new-object "System.Data.DataTable"
    $cn = new-object System.Data.SqlClient.SqlConnection >
"server=$svr;database=master;Integrated Security=sspi" 
    $cn.Open()
    $sql = $cn.CreateCommand()
    $svr
    $sql.CommandText = "EXEC master.dbo.xp_fixeddrives"
    $rdr = $sql.ExecuteReader()
    $dt.Load($rdr)
    $cn.Close()
    $dt | Format-Table -autosize
}

##############FINISH########################

 Related Posts

SQL Server Database Size and Free Disk Space Daily Report

SQL Server database free space with sys.dm_os_performance_counters


Author: Jack Vamvas (http://www.sqlserver-dba.com)

******** *******

Enjoy this post? Enter your email address for updates on new posts:

Delivered by FeedBurner

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer