![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Calculate copy time | VB Script | |||
| how to calculate the system uptime | VB Script | |||
| Calculate sum | PowerShell | |||
| How to use http://servername as the DriveInfo.Root? ...a more basic question | PowerShell | |||
| Calculate % of CPU time for every active process | PowerShell | |||