Hey Guys i got a tricky one that has been making things more difficult than it should. currently i'm using to collect the file path and size of our .bkf files.
$ntbackup = "E:\EXCHDATA\Backup"
$OFS = "`r`n"
$Paths = get-childitem e:\exchdata\backup -recurse -include *.bkf
$bkfsize = (get-childitem $ntbackup -recurse | Where-Object {$_.PSIsContainer -eq $False} | Sort-Object)
foreach ($i in $bkfsize)
{
$ntbackupsub = (get-childitem $i.Fullname -recurse | Measure-object -property length -sum)
$outfile += "`r`n" + $i.Fullname + " -- " + "{0:N2}" -f ($ntbackupsub.sum / 1MB) + " MB."
$paths
}
Which out puts the three .bkf's in each residing folder, which was fine until i was instructed to change a few things around.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG13\BackupC1SG13_.bkf -- 18,074.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG13\BackupC1SG13_2.bkf -- 28,810.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG13\BackupC1SG13_3.bkf -- 27,824.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG14\BackupC1SG14_.bkf -- 16,528.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG14\BackupC1SG14_2.bkf -- 23,944.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG14\BackupC1SG14_3.bkf -- 23,685.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG15\BackupC1SG15_.bkf -- 17,171.41 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG15\BackupC1SG15_2.bkf -- 29,008.42 MB.
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG15\BackupC1SG15_3.bkf -- 28,256.41 MB.
I would like the three .bkf files nested under their residing folder for an easier read. for example
E:\EXCHDATA\Backup\Backup13-15\BackupC1SG13
BackupC1SG13_.bkf -- 18,074.41 MB.
BackupC1SG13_2.bkf -- 28,810.41 MB
BackupC1SG13_3.bkf -- 27,824.41 MB.
unfortunately this has been harder than i thought and was wondering if anyone has any suggestions?
Weird thing is I sort of get the format i'm looking for when i run this minor syntax, but when i try to convert length to MB it looses it's format integrity. Below looks more like the format we'd like, but i'm having a hard time converting length to Mb with out losing the below format.
get-childitem e:\exchdata\backup -recurse -include *.bkf
Directory: Microsoft.PowerShell.Core\FileSystem::E:\exchdata\backup\Backup1-3\BackupC1SG1
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/14/2008 3:12 AM 1784798208 BackupC1SG1_.bkf
-a--- 4/23/2008 11:47 AM 2876798668 BackupC1SG1_2.bkf
Directory: Microsoft.PowerShell.Core\FileSystem::E:\exchdata\backup\Backup1-3\BackupC1SG2
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 4/14/2008 3:35 AM 1622295244 BackupC1SG2_.bkf
-a--- 4/23/2008 12:15 PM 2799112396 BackupC1SG2_2.bkf