![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Free Disk Space on network share Hello, I have a cmd.exe batch script (a one-liner, actually) which returns the amount of free disk space on each share of a network drive. The core of the line is dir \\server\share1 | grep free. (Basically the same as Unix grep. I'm not sure where it came from, but its there). Anyway, I want to do this in Powershell instead. But Dir is just an alias for Get-ChildItem and doesn't say anything about free disk space. I also looked at Get-Item, but System.IO.DirectoryInfo doesn't seem to be aware of the free space either. Get-WMIObject is out because the share is on a Netapp. (I got a message saying that the RPC server isn't available). I don't really want to use WMI anyway since this information *SHOULD* (IMO) be available to Powershell directly. And I can't figure out how to run cmd's 'dir' command from Powershell either. Anyone have any ideas? Thanks! |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Free Disk Space on network share Oh... I guess I do have access to "dir": (cmd /c "dir") -match "bytes free" But this is pretty lame. There has to be a better way. Any thoughts? Clint Bodine wrote: > Hello, > > I have a cmd.exe batch script (a one-liner, actually) which returns > the amount of free disk space on each share of a network drive. The > core of the line is dir \\server\share1 | grep free. (Basically the > same as Unix grep. I'm not sure where it came from, but its there). > > Anyway, I want to do this in Powershell instead. But Dir is just an > alias for Get-ChildItem and doesn't say anything about free disk > space. I also looked at Get-Item, but System.IO.DirectoryInfo doesn't > seem to be aware of the free space either. Get-WMIObject is out > because the share is on a Netapp. (I got a message saying that the RPC > server isn't available). I don't really want to use WMI anyway since > this information *SHOULD* (IMO) be available to Powershell directly. > And I can't figure out how to run cmd's 'dir' command from Powershell > either. > > Anyone have any ideas? Thanks! |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Free Disk Space on network share Try: # Assumes V: does not already exists $map = new-Object -com Wscript.Network $map.MapNetworkDrive("v:","\\$computer\c$") $fso = new-Object -com Scripting.FileSystemObject $do = $fso.getdrive("v") $do.AvailableSpace $do.TotalSize # to see everything this object offers $do |Format-List * $map.RemoveNetworkDrive("v:") Gaurhoth http://thepowershellguy.com/blogs/gaurhoth/ "Clint Bodine" <csbodine@gmail.com> wrote in message news:1175186175.831882.84390@e65g2000hsc.googlegroups.com... > Oh... I guess I do have access to "dir": > > (cmd /c "dir") -match "bytes free" > > But this is pretty lame. There has to be a better way. > > Any thoughts? > > Clint Bodine wrote: >> Hello, >> >> I have a cmd.exe batch script (a one-liner, actually) which returns >> the amount of free disk space on each share of a network drive. The >> core of the line is dir \\server\share1 | grep free. (Basically the >> same as Unix grep. I'm not sure where it came from, but its there). >> >> Anyway, I want to do this in Powershell instead. But Dir is just an >> alias for Get-ChildItem and doesn't say anything about free disk >> space. I also looked at Get-Item, but System.IO.DirectoryInfo doesn't >> seem to be aware of the free space either. Get-WMIObject is out >> because the share is on a Netapp. (I got a message saying that the RPC >> server isn't available). I don't really want to use WMI anyway since >> this information *SHOULD* (IMO) be available to Powershell directly. >> And I can't figure out how to run cmd's 'dir' command from Powershell >> either. >> >> Anyone have any ideas? Thanks! > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Free Disk Space on network share "Gaurhoth" <gaurhoth@live.com> wrote in message news:OwP644ncHHA.4032@TK2MSFTNGP02.phx.gbl... > Try: > > # Assumes V: does not already exists > $map = new-Object -com Wscript.Network > $map.MapNetworkDrive("v:","\\$computer\c$") > $fso = new-Object -com Scripting.FileSystemObject > $do = $fso.getdrive("v") > $do.AvailableSpace > $do.TotalSize You don't even need to map the drive first: $do = $fso.getdrive("\\$computer\c$") .... will work equally. Or as a one-liner: (new-object -com scripting.filesystemobject).getdrive("\\computer\c$").availablespace Jacques |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Misreported Used/Free Disk Space | Shade_C | Vista General | 3 | 04-17-2008 07:11 AM |
| Out of disk space error at installations, though 100 Gb free space | Evagoud | Vista General | 5 | 11-04-2007 02:48 AM |
| free disk space is reduced while copying over network | joseph millman | Vista file management | 0 | 10-12-2007 12:18 PM |
| free disk space is reduced while copying over network | joseph millman | Vista networking & sharing | 0 | 10-12-2007 12:18 PM |
| free disk space is reduced while copying over network | joseph millman | Vista performance & maintenance | 0 | 10-12-2007 12:18 PM |