Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

Free disk space on drives using Powershell

01 May,2010 by Tom Collins

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: Tom Collins (http://www.sqlserver-dba.com)


Share:

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 on Free disk space on drives using Powershell


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