Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

need script for space util Expand / Collapse
Author
Message
Posted Saturday, March 23, 2013 9:33 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, April 03, 2014 2:14 PM
Points: 746, Visits: 1,702
Hi,

Can anyone share TSQL script for displaying each drive wise Total, Free , Free% space utilizaiton report so that if it is less than 30% I need to send out an email as output as Daily Monitor Activity. Looking for a script which can work on sql 2000 and above versions.

Thanks in Advance.
Post #1434659
Posted Sunday, March 24, 2013 11:46 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
The best way I have found to do this is using WMI but not from within T-SQL, from a PowerShell script. Use Get-WmiObject to read from class Win32_LogicalDisk against Windows 2000 Servers, and Win32_Volume (picks up mount points) against Windows 2003+ servers.

edit: fix name of class Win32_Volume...typed Win32_LogicalVolume from memory


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1434685
Posted Sunday, March 24, 2013 12:32 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, April 03, 2014 2:14 PM
Points: 746, Visits: 1,702
installing powershell do we any security risks as mine windows 2003. am not sure we can download sdk which has powershell 2.0.

can u share the script?
Post #1434691
Posted Sunday, March 24, 2013 12:39 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
Oracle_91 (3/24/2013)
installing powershell do we any security risks as mine windows 2003. am not sure we can download sdk which has powershell 2.0.

can u share the script?

PowerShell is a safe option. Much safer than doing the same via T-SQL. You ought to read about it and become familiar. It is the platform Microsoft has chosen for all server-class software administration including SQL, Windows, IIS, Active Directory, Exchange, etc.

I do not have scripts I can easily share. My admin scripts are tied into utility databases and other environment aspects. Here is an example for you to try against your 2003 server:

$Computer = "ComputerName"
Get-WMIObject Win32_Volume -Filter "DriveType=3" -Computer $Computer | Select SystemName,DeviceID,VolumeName,FileSystem,BlockSize,NumberOfBlocks,@{Name="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="freespace(GB)";Expression={"{0:N1}" -f($_.freespace/1gb)}},@{Name="freespace(%)";Expression={"{0:N1}" -f(($_.freespace/$_.size)*100)}})


Just change the variable value to your computer name.


__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1434692
Posted Sunday, March 24, 2013 9:51 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, April 03, 2014 2:14 PM
Points: 746, Visits: 1,702
Hi,

Thanks for the script. I installed powershell on one of my windows 7 machine. However, i am getting below error.Not sure, If I am using right command line. I replace the computer name with my PC name and tried executing and I dont see output. Please correct me if am doing something wrong as I am new to powershell.

D:\>powershell.exe -noexit &'d:\b.ps1'
Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS D:\>
PS D:\> exit
Post #1434739
Posted Sunday, March 24, 2013 10:00 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
Read up on how to call a script using powershell.exe. That does nit look right. The ampersand is for code-blocks iirc. Just run the stuff I gave you at a PowerShell prompt to get comfortable before moving on to using saved scripts. Lookup Professor PowerShell, and look into book PowerShell 3.0 in 30 Days of Lunches.

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1434740
Posted Sunday, March 24, 2013 10:13 PM
Right there with Babe

Right there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with BabeRight there with Babe

Group: General Forum Members
Last Login: Thursday, April 03, 2014 2:14 PM
Points: 746, Visits: 1,702
Hi,
Getting below error messgae when I execute it at powershell command.

PS D:\>
PS D:\> $Computer = "WIN7-PC"
PS D:\> Get-WMIObject Win32_Volume -Filter "DriveType=3" -Computer $Computer | Select SystemName,DeviceID,VolumeName,FileSyst
em,BlockSize,NumberOfBlocks,@{Name="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="freespace(GB)";Expression={"{0:N
1}" -f($_.freespace/1gb)}},@{Name="freespace(%)";Expression={"{0:N1}" -f(($_.freespace/$_.size)*100)}})
Unexpected token ')' in expression or statement.
At line:1 char:346
+ Get-WMIObject Win32_Volume -Filter "DriveType=3" -Computer $Computer | Select SystemName,DeviceID,VolumeName,FileSystem,Bl
ockSize,NumberOfBlocks,@{Name="size(GB)";Expression={"{0:N1}" -f($_.size/1gb)}},@{Name="freespace(GB)";Expression={"{0:N1}"
-f($_.freespace/1gb)}},@{Name="freespace(%)";Expression={"{0:N1}" -f(($_.freespace/$_.size)*100)}}) <<<<
+ CategoryInfo : ParserError: ():String) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken

PS D:\>



Post #1434741
Posted Monday, March 25, 2013 6:52 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: 2 days ago @ 9:25 AM
Points: 7,070, Visits: 12,523
I may have picked up am extra trailing parent when it copied it from my script. Try removing that and see what you get. Better yet, deconstruct the command and understand what its doing, then tell me what's wrong with it

__________________________________________________________________________________________________
There are no special teachers of virtue, because virtue is taught by the whole community. --Plato

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1434883
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse