header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Excel report to show total data amount per hard drive
Last Post 04 Nov 2008 06:42 PM by jason_stephens. 2 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
amargesonUser is Offline
New Member
New Member
Posts:4
Avatar

--
23 Oct 2008 05:51 PM  

I'm currently trying to make a script to make an excel spreadsheet that will show the current amount of drive space used in MB on a server.  I've adapted a script I found on the net to do this, but I'm having trouble.  Here's the script:

 

$cred = Get-Credential ""
$erroractionpreference = "SilentlyContinue"
$a = New-Object -comobject Excel.Application
$a.visible = $True

$b = $a.Workbooks.Add()
$c = $b.Worksheets.Item(1)

$c.Cells.Item(1,1) = "Machine Name"
$c.Cells.Item(1,2) = "Drive"
$c.Cells.Item(1,3) = "Data size (MB)"

$d = $c.UsedRange
$d.Interior.ColorIndex = 19
$d.Font.ColorIndex = 11
$d.Font.Bold = $True
$d.EntireColumn.AutoFit($True)

$intRow = 2

$colComputers = get-content C:\pstools\mailservers.txt
foreach ($strComputer in $colComputers)
{
$colDisks = get-wmiobject Win32_LogicalDisk -Credential $cred -computername $strComputer -Filter "DriveType = 3"
foreach ($objdisk in $colDisks)
{
$c.Cells.Item($intRow, 1) = $strComputer.ToUpper()
$c.Cells.Item($intRow, 2) = $objDisk.DeviceID
$c.Cells.Item($intRow, 3) = "{0:P0}" -f ($objDisk.Size/1MB-$objDisk.FreeSpace/1MB)
$intRow = $intRow + 1
}

 The problem is the returns are weird large percentages that don't make any sense.

Any idea what I'm doing wrong?

amargesonUser is Offline
New Member
New Member
Posts:4
Avatar

--
23 Oct 2008 07:13 PM  

I feel stupid.  Excel was just converting it to %.  Coupled with GB being in base8, it didn't look right at all.  Once I corrected this manually in Excel, it's fine.

Can Powershell set the column to number instead of % automatically?

jason_stephensUser is Offline
New Member
New Member
Posts:15
Avatar

--
04 Nov 2008 06:42 PM  

I just posted my particular solution to logging drives of servers.

 

powershellcommunity.org/Forums/tabid/54/forumid/14/postid/3332/view/topic/Default.aspx

You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer