Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

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

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-11-2008   #1 (permalink)
Gregor
Guest


 

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

Hello

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

Output:

Name TotalFreespace TotalSize
C:\ 63851022848 72818371072

The new Output

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

Thanks for any help

Gregor


My System SpecsSystem Spec
Old 01-11-2008   #2 (permalink)
Shay Levi
Guest


 

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


Try:


$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
http://scriptolog.blogspot.com
Quote:

> Hello
>
> 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
> Output:
>
> Name TotalFreespace TotalSize
> C:\ 63851022848 72818371072
> The new Output
>
> Name, Freespace in GBs, TotalSize in GBs, Freespace in %, UsedSpace %
>
> Thanks for any help
>
> Gregor
>

My System SpecsSystem Spec
Old 01-11-2008   #3 (permalink)
Gregor
Guest


 

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

Hello Shay

Thanks

I have problems with name

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

Do you have a idea?

Thanks
Gregor


"Shay Levi" <no@xxxxxx> wrote in message
news:8766a94418eb48ca224f09def646@xxxxxx
Quote:

>
> Try:
>
>
> $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
> http://scriptolog.blogspot.com
>
Quote:

>> Hello
>>
>> 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
>> Output:
>>
>> Name TotalFreespace TotalSize
>> C:\ 63851022848 72818371072
>> The new Output
>>
>> Name, Freespace in GBs, TotalSize in GBs, Freespace in %, UsedSpace %
>>
>> Thanks for any help
>>
>> Gregor
>>
>
>
My System SpecsSystem Spec
Old 01-11-2008   #4 (permalink)
Kirk Munro [MVP]
Guest


 

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

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]
Poshoholic
http://poshoholic.com


"Gregor" <nospam@xxxxxx> wrote in message
news:801AC0B9-488C-4144-9A1D-87562DC987DF@xxxxxx
Quote:

> Hello Shay
>
> Thanks
>
> I have problems with name
>
> Error message: The term 'name' is not recognized as a cmdlet, function,
> operable program
>
> Do you have a idea?
>
> Thanks
> Gregor
>
>
> "Shay Levi" <no@xxxxxx> wrote in message
> news:8766a94418eb48ca224f09def646@xxxxxx
Quote:

>>
>> Try:
>>
>>
>> $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
>> http://scriptolog.blogspot.com
>>
Quote:

>>> Hello
>>>
>>> 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
>>> Output:
>>>
>>> Name TotalFreespace TotalSize
>>> C:\ 63851022848 72818371072
>>> The new Output
>>>
>>> Name, Freespace in GBs, TotalSize in GBs, Freespace in %, UsedSpace %
>>>
>>> Thanks for any help
>>>
>>> Gregor
>>>
>>
>>
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculate sum Jason1008 PowerShell 3 06-16-2008 11:50 AM
Calculate Printer Page Count Per User Jeffrey Tadlock PowerShell 3 07-10-2007 03:34 PM
Unable to calculate windows experience index Craig Cockburn Vista General 10 04-08-2007 02:06 PM
How to use http://servername as the DriveInfo.Root? ...a more basic question Michael Herman \(Parallelspace/OpenCanal\) PowerShell 4 04-04-2007 01:49 PM
Calculate % of CPU time for every active process krukinews@gmail.com PowerShell 0 09-27-2006 05:19 AM


Vistax64.com 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 2005-2008

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 47 48 49 50 51