Add Size Column in Powershell Script.


hi, i'm working in script determine files didnt have been modified in 5 years, need add sizes of each path, can me?

script:

dir f:\ -recurse |  select fullname,creationtime,lastwritetime,  @{name="age";expression={(get-date)-$_.lastwritetime}},                              @{name="days";expression={[int]((get-date)-$_.lastwritetime).totaldays}},                              @{name="owner";expression={(get-acl $_.fullname).owner}} |                              where {$_.days -ge 1825} | sort days -descending 

thank u!

you can add size adding length property. can placed anywhere inside select command, such before fullname, in middle somewhere, or @ end (after @{name="owner";expression={(get-acl $_.fullname).owner}}) -- it's you. length (think, size) report in bytes, should, if you're challenge, can have display in it's proper size group: bytes, mb, kb, gb, etc, based on number of bytes. here's post wrote how that: http://tommymaynard.com/script-sharing-return-file-sizes-in-bytes-kbs-mbs-and-gbs-at-the-same-time-2015.


Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Azure MFA with Azure AD and RDS

Failed to setup initiator portal. Error status is given in the dump data.

Invalid pointer on gpresult /h gpreport.html