Powershell command for file size

Via powershell, how can I query the Exchange 2007 mailbox servers to get the file size of the edb files?  We have four exchange databases on one lun (volume) so we have four edb files on the G drive.  We have four folders and in each folder is where the edb files are contained.  I wouldnt mind getting the folder size and all sub folder sizes in the top level folder.....just need some powershell polishing.
tpaukovitsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mspieglerCommented:
0
paarunCommented:
I may be wrong, but will putting a dir command in batch file not solve your problem?
0
martingagnonCommented:
I've tested one of the script from the link that mspiegler provided and it is working great :

$exchangeservers = Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
foreach ($server in $exchangeservers)
{
    $db = Get-MailboxDatabase -server $server
    foreach ($objItem in $db)
    {
    $edbfilepath = $objItem.edbfilepath
    $path = "`\`\" + $server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2)
    $dbsize = Get-ChildItem $path
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    $ReturnedObj | Add-Member NoteProperty -Name "Size (MB)" -Value ("{0:n2}" -f ($dbsize.Length/1024KB))
    Write-Output $ReturnedObj
    }
}

Thanks!
0
MSSPs - Are you paying too much?

WEBINAR: Managed security service providers often deploy & manage products from a variety of solution vendors. But is this really the best approach when it comes to saving time AND money? Join us on Aug. 15th to learn how you can improve your total cost of ownership today!

tpaukovitsAuthor Commented:
yes, thank martingangnon this is exactly what I was looking for. how can I modifiy this so it's exported via csv file?
0
martingagnonCommented:
Use this script then.

$exchangeservers = Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
$AllServers = @()
foreach ($server in $exchangeservers)
{
    $db = Get-MailboxDatabase -server $server
    foreach ($objItem in $db)
    {
    $edbfilepath = $objItem.edbfilepath
    $path = "`\`\" + $server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2)
    $dbsize = Get-ChildItem $path
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    $ReturnedObj | Add-Member NoteProperty -Name "Size (MB)" -Value ("{0:n2}" -f ($dbsize.Length/1024KB))
    $AllServers += $ReturnedObj
    }
}

$AllServers |export-csv c:\test.csv -notype -force
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tpaukovitsAuthor Commented:
perfect!!! couldn't be any better!!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.