Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Free Disk Space

Reply
 
Old 11-20-2008   #1 (permalink)
Pat


 
 

Free Disk Space

I haven't used Powershell before and I am new to scripting.

I need to run a scrip to report available free disk space on 20 plus Servers.
Is this possible with Powershell and how hard is it to create?



Thank you in advance

My System SpecsSystem Spec
Old 11-20-2008   #2 (permalink)
Jonathan Noble


 
 

Re: Free Disk Space

It's easy enough... :-)

Essentially, you're going to use WMI to get the disk space. You have
more options for dealing with the list of servers.

Let's say you've got a file called servers.txt which has a server name
per line...

foreach ($server in (get-content servers.txt)) {
$server
get-wmiobject win32_LogicalDisk -computername $server -filter
"DriveType=3" |
format-table DeviceID,Freespace -autosize
}

This picks each server name out of the file and uses it in a script
block which:
Displays the server name
Gets the local logical hard drives (drivetype 3) using WMI and pipes
it to
Format-table to output the freespace

If you want to test it out without hitting your servers, or don't have
a file, you can stick an array of computer names in the foreach like:
foreach ($server in "localhost",".")

The freespace is in bytes, so you probably want to format the output a
bit better with something like this:
format-table DeviceID,@{Label="Gb Free(Approx.)";Expression={[int]
($_.Freespace/1GB)}} -autosize}

I wrote a blog post a while ago which checks disk space for all the
machines in an OU, which you may wish to check out at
http://jonoble.spaces.live.com/blog/...94A5!545.entry
My System SpecsSystem Spec
Old 11-25-2008   #3 (permalink)
Jacob Sampson


 
 

RE: Free Disk Space

Pat,

I have created a script that you will like that will gather what you want
and more. If you are interested shoot me an email and I will give it to you
and explain it. I would post it here but it will look very ugly.

jsampson@xxxxxx

"Pat" wrote:
Quote:

> I haven't used Powershell before and I am new to scripting.
>
> I need to run a scrip to report available free disk space on 20 plus Servers.
> Is this possible with Powershell and how hard is it to create?
>
>
>
> Thank you in advance
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
No free disk space error even though there is enough disk space on Windows Vista x64 Vista installation & setup
Query disk free space.... PowerShell
Misreported Used/Free Disk Space Vista General
Out of disk space error at installations, though 100 Gb free space Vista General
disk free space anomaly Vista performance & maintenance


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46