DriveInfo in GBs and calculate used space in GBs, in Percent



  • 1. Server 2008 / $user.SetInfo() error
    I am trying to run the simplest of Powershell scripts in Windows Server 2008. I an trying to change the FullName property of a local user. This scripts works fine on XP (the local user "testuser" exists on the on WS2K8 server I'm running on): $user = [ADSI]"WinNT://./testuser,user" $user.Fullname="Test User" $user.SetInfo() When I hit the SetInfo() line, I get this error: Exception calling "SetInfo" with "0" argument(s): "The filename, directory name, or volume label syntax is incorrect. ( Exception from HRESULT: 0x8007007B)" If i do $, it dumps the list of properties and values with the new value reflected, i just want actually write the info. Googling had turned up nothing useful. Thanks. --> A.J. Fried
  • 2. Loading Registry hive with PowerShell
    Hello, how can I load and unload a Registry hive with PowerShell? Of course, I could call reg.exe to load and unload my hive, but this seems not very beautiful for me. Further, there are different versions of reg.exe which have a different parameter ordering. I trying to modify the Default User ntuser.dat with PowerShell. Can anybody give some hints? Please bear with me, I just starting to use PowerShell... Thanks for your reply! Andi
  • 3. excel object
    To use excel object , new-object -comobject excel.application If my machine is installed only with excel *VIEWER* and not the full-blown excel applications, will the above object works ?
  • 4. Searching for Patterns in Hashtable
    I have a hashtable that has been formed by reading in values from an xml file, so I end up with a hashtable with keys and corresponding values. What I need to do is search through for keys that begins with specific patterns, can I use the containskey metthod with some kind of filter? So far I am working around it using the following:- $result = $hash1.keys | select-object | Where-Object {$_ -like "PATTERN*"} I can then check if $result.count is greater than zero. This seems a little clunky to me and was wondering if there is a better way around this? Thanks.
  • 5. How to remove blanks line from a text outpu file
    If I wrote a script file like this : Get-Date | format-list DayOfWeek | out-file -Encoding ascii date.txt It write Day of week in date.txt text file but the output text file starts with two blank line (like Carriage Return) and then : "DayOfWeek : Thursday" Is there any way to format the output text file so the "DayOfWeek : Thursday" starts at the first line of the text file (without blank lines)? Thanks in advance. Ing. Cosimo Mercuro

DriveInfo in GBs and calculate used space in GBs, in Percent

Postby Gregor » Sat, 12 Jan 2008 16:17:58 GMT


I would like DriveInfos in GBs and  calculate used space

I have:

$drives = [System.IO.DriveInfo]::GetDrives()
$drives | where {$_.DriveType -eq "Fixed"} | Format-Table Name, 
TotalFreeSpace, TotalSize -auto


Name TotalFreespace TotalSize
C:\    63851022848  72818371072

The new Output

Name, Freespace in GBs, TotalSize in GBs, Freespace in %, UsedSpace %

Thanks for any help


Re: DriveInfo in GBs and calculate used space in GBs, in Percent

Postby Shay Levi » Sat, 12 Jan 2008 16:54:06 GMT


$FreeGB = @{label="Free (GB)";expression={"{0:N2}" -f ($_.TotalFreeSpace/1gb)}}
$TotalSizeGB = @{label="TotalSize (GB)";expression={"{0:N2}" -f ($_.TotalSize/1gb)}}
$PFreespace = @{label="% Free";expression={"{0:P2}" -f ($_.TotalFreeSpace/$_.TotalSize)}}
$PUsedSpace = @{label="% UsedSpace";expression={"{0:P2}" -f (($_.TotalSize-$_.TotalFreeSpace)/$_.TotalSize)}}

[System.IO.DriveInfo]::GetDrives() | where {$_.DriveType -eq "Fixed"} | ft 
name,$FreeGB,$TotalSizeGB,$PFreespace,$PUsedSpace -auto

Shay Levi
$cript Fanatic

Re: DriveInfo in GBs and calculate used space in GBs, in Percent

Postby Gregor » Sat, 12 Jan 2008 18:19:50 GMT

Hello Shay


I have problems with name

Error message: The term 'name' is not recognized as a cmdlet, function, 
operable program

Do you have a idea?


Re: DriveInfo in GBs and calculate used space in GBs, in Percent

Postby Kirk Munro [MVP] » Sat, 12 Jan 2008 23:24:11 GMT

The last two lines of Shay's script are actually one line, wrapped.  Make 
that one line and you should be good to go.

Kirk Munro [MVP]

Similar Threads:

1.40 GBs of hard disk space gone

My computer , a Sony Vaio, running windows vista , has a 105 GB harddisk, 
even taking into account the whole 1000mb=1Gb v.s. 1024mb=1Gb issue, since i 
am missing 40Gbs, that i cannot find, look at, or delete. I open up the 
hardrive, highlight all the sub folders, and look at the properties, the 
total GB count comes up as 65GB, but then I go to the computer as a whole, 
and it shows the disk as full, 105 of 105 gb used. I have looked into 
(ALL)temporary files, I have defraged my hardrive, I have done disk clean up 
repeatedly, and i have conducted several disk scans. I cannot find were this 
40gbs is going to; is there somewhere i just havent looked?

2.Where has all the GBs gone?

I'm trying to figure out how I managed to use up so much space on my hard 
drive in just 9 months.  I have a 120GB hdd, which converts to approx 111GB.  
HP Recovery used 8.34 leaving me 103GB.

Out of 103GB, I currently have 30.8 free space.  This is incredible that 
I've used 72.2 GB in 9 months.  My 7-year old desktop with XP has 80GB with 
55GB free space.

Does Vista use this much space?  If I right click on Windows, select 
Properties, it calculates 12.7 GB.  Is this a true number?  If so, I've done 
this for every folder and the large ones are Program Files 12.1 and my user 
is 17.7GB.  No other users.  Pagefile.sys 3.1GB and hiberfil.sys 3.4GB.  Many 
other misc folders add up to 5.75 GB. 

All these files add up to 55.15 GB.  That leaves 17GB that I can't account 
for.  Where's that missing 17GB?  

3.SP1 with 8 GBs DDR2 667Mhz problem

Hello all:
   I had 4 2GB sticks of  667 Mhz RAM left over from upgrading a couple of 
pcs to 800 Mhz RAM so I pulled out the 3 GB 800 Mhz RAM from my Vista 
Ultimate x64 PC and put in the 8 GBs of 667 Mhz RAM.  It seems to work ok 
after a couple of re-boots is quite a bit slower to boot up.  
With 3 GBs of 800 Mhz it was taking about 90 seconds to 2 mins.  With 8 GBs 
of 667 Mhz it is taking 4 1/2 minutes.  Shutdown time seems about the same.  
Intel specs say my DG965WH board can use 8 GB of 667 Mhz.  Is the slow boot 
because Windows is taking more time to load more data in memory than it would 
with 3 GBs?  Or, is the problem of using more than 4 GB's with Vista using 
all 4 slots not solved by the latest Intel Bios and SP1?  The PC was actually 
working great with 3 GBs but I wanted to see if it would work with 8 GBs to 
make it easier to install & use a couple of virtual operating systems.  I 
don't really NEED to have that capability but I just wanted to learn more 
about using Virtual operating systems.  I'd be interested in comments from 
others using 8 GBs of RAM and how it's working on their pc. tucson

4.Accessing 4 GBs Physical Memory with Vista Enterprise x64

5.263 GBs taken up within hours.

I need some help guys..
I was dowloaing the trail version of After Effects off
After the installation I downloaded a few torrents.
Computer is running smooth, but it went from 64gb to 263gb within a few hours.
Can someone help me?


6. Upgrade Memory from 3 to 5 GBs and I see 3,5GBs

7. Recovering lost GBs or sorting folders on Windows XP Home edition

8. Losing massive amount of GBs

Return to powershell


Who is online

Users browsing this forum: No registered users and 70 guest