Last modified item time in user share

rated by 0 users
This post has 1 Reply | 1 Follower

Not Ranked
Posts 1
Duffman59000 Posted: 03-21-2012 2:48 PM

Hi all,

I am trying to put together a little script to check the last modified time of a user share and i keep running into brick walls Angry

essentially i have a share on a server with individual user shares, IE:


i am trying to get a report that will search each folder individually and report according to the example below

Username        LastWriteTime                  ItemSize
User 1              3/21/2012 6:05:33 PM     5.7 GB
User 2              3/18/2012 3:57:28 PM     1.3 GB


i have experimented with:

Get-ChildItem -Recurse | Where-Object { $_.PSIsContainer } | Sort-Object LastWriteTime -Descending | Select-Object Name,LastWriteTime -First 1

but this returns the subfolder name's information and recurse into all user shares so i will get an output such as

Name               LastWriteTime
Contacts          3/21/2012 6:05:33 PM

not sure what process i should take to get the desired output, any help or finger in the correct direction would be greatly appreciated

Thanks in advance

Top 25 Contributor
Posts 296
Microsoft MVP
Top Contributor

Try something like this

Get-ChildItem -Path "C:\PersonalData\MyBooks\PowerShell and WMI" -Recurse |
where { $_.PSIsContainer} |
foreach {
 $size = Get-ChildItem -Path $_.FullName -Recurse | measure -Sum Length | select -ExpandProperty Sum
 Add-Member -InputObject $($_) -MemberType NoteProperty -Name Size -Value $size

 $_ | select Fullname, LastWriteTime, @{N="Size(MB)"; E={[math]::Round(($_.Size/1mb), 2)}}
} | Format-Table -AutoSize -Wrap

You will need to change MB to GB in the select statement

Page 1 of 1 (2 items) | RSS
Copyright 2012 All rights reserved.