powershell folder size, last modified, author attributes

I need a simple one line powershell script to add to the below that will show me for each item the 'date modifided', 'date created', 'size' and 'author' attributes, can this be done in powershell, if so how would I finish the command off? the first part gets me just the folders which is what I am after:


Get-ChildItem \\server\share -Recurse | Where-Object{($_.psiscontainer)} |
LVL 4
pma111Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Dope ADMSr. Systems EngineerCommented:
A one-liner....with size, curious to see if someone can come up with that.
The below is not what you've requested, but in case you are interested....

Looking forward for someone to come up with a one liner for size, that'll help me a great deal with my scripts.

ps: Also, assuming it's for a file server, have you considered using FSRM?


$mainPath = Read-Host('Enter U$ drrive main path')

function Get-UdriveSize($pathName){
$item = $pathName
$params = New-Object System.Collections.Arraylist
$params.AddRange(@("/L","/S","/NJH","/BYTES","/FP","/NC","/NDL","/TS","/XJ","/R:0","/W:0"))
$countPattern = "^\s{3}Files\s:\s+(?<Count>\d+).*"
$sizePattern = "^\s{3}Bytes\s:\s+(?<Size>\d+(?:\.?\d+)).*"
$return = robocopy $item NULL $params
If ($return[-5] -match $countPattern) {
    $Count = $matches.Count
}
If ($Count -gt 0) {
    If ($return[-4] -match $sizePattern) {
        $Size = $matches.Size
    }
} Else {
    $Size = 0
}
$object = New-Object PSObject -Property @{
    FullName = $item
    Count = [int]$Count
    Size = "{0:N1}" -f (([math]::Round($Size,2)) / (1024*1024*1024))
}
$object.pstypenames.insert(0,'IO.Folder.Foldersize')
Write-Output $object
$Size=$Null
}
#############################################################################################

cd $MainPath
$Udrives = (Get-ChildItem $MainPath).name

#defining custom object
$outarray  = @() #array contstruct for data export csv or txt 

ForEach ($element in $Udrives) { #loop through each folder and compute file size under the user drive. 

$customOBJ = "" | select "Folder","SizeMB" #Object construct for the Select-Object

get-UdriveSize -pathName $element | Select-Object FullName,size | Export-Csv 'C:\FolderSizeReport2.csv' -Append

}

Open in new window

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
Bill PrewIT / Software Engineering ConsultantCommented:
Your example will list folders.  What do you mean by "author" of a folder?


»bp
0
aikimarkCommented:
Although not a "one line" solution, this does return everything but the "author" property, which Bill already asked about.
Get-ChildItem \\server\share -Recurse | Where-Object{($_.psiscontainer)} |
    %{ 
        New-Object -TypeName PSObject -Property @{

        'Path' = $_.fullname
        'Date Created' = $_.CreationTime
        'Date Modified' = $_.LastWriteTime
        'Size' = (measure -sum -property length -InputObject (Get-ChildItem $_.fullname | ?{$_.psiscontainer -eq $false})).sum
        'Author' = 'unavailable'

        }
    }

Open in new window

0
Check Out How Miercom Evaluates Wi-Fi Security!

It's not just about Wi-Fi connectivity anymore. A wireless security breach can cost your business large amounts of time, trouble, and expense. Plus, hear first-hand from Miercom on how WatchGuard's Wi-Fi security stacks up against the competition plus a LIVE demo!

pma111Author Commented:
If you right click the headers in a folder in windows explorer author is an option to tick just like date modified
0
aikimarkCommented:
Do you see any "authors" data related to a folder?
0
pma111Author Commented:
I do in some cases, not all, it lists a domain username in the authors column if I right click a folder, and tick the option.
0
aikimarkCommented:
Ah.  There was a way after all.
Get-ChildItem \\server\share -Recurse | Where-Object{($_.psiscontainer)} |
    %{ 
        New-Object -TypeName PSObject -Property @{

        'Path' = $_.fullname
        'Date Created' = $_.CreationTime
        'Date Modified' = $_.LastWriteTime
        'Size' = (measure -sum -property length -InputObject (Get-ChildItem $_.fullname | ?{$_.psiscontainer -eq $false})).sum
        'Author' = (Get-Acl $_.fullName).owner

        }
    }

Open in new window

0
Rather StayanoCommented:
Looking forward for someone to come up with a one liner for size, that'll help me a great deal with my scripts.

With this approach, I couldn't find a way to get author of each file, but the rest are here:
get-childitem | where {!$_.PSIsContainer} | Format-List FullName,LastWriteTime,CreationTime,Length

Open in new window

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.