Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

$var.droppath.TrimEnd() # is the parent folder

all child folder were named with "10.**"...

I can use the following line to get all child folders:

get-childitem $var.droppath.TrimEnd()|where-object {$_.name -match "10."} 

here is a list of one of the childitem I got:

 PSPath            : Microsoft.PowerShell.Core\FileSystem::\\sharespace\test1\10.00.1220.00
 PSParentPath      : Microsoft.PowerShell.Core\FileSystem::\\sharespace\test1\     PSChildName       : 10.00.1220.00
 PSProvider        : Microsoft.PowerShell.Core\FileSystem
 PSIsContainer     : True
 Name              : 10.00.1220.00
 Parent            : CU
 Exists            : True
 Root              : \\sharespace
 FullName          : \\sharespace\test1\10.00.1220.00
 Extension         : .00
 CreationTime      : 1/8/2011 3:24:01 PM
 CreationTimeUtc   : 1/8/2011 7:24:01 AM
 LastAccessTime    : 6/25/2011 2:51:33 AM
 LastAccessTimeUtc : 6/24/2011 6:51:33 PM
 LastWriteTime     : 6/25/2011 2:51:33 AM
 LastWriteTimeUtc  : 6/24/2011 6:51:33 PM
 Attributes        : Directory
 BaseName          : 10.00.4272.00
 Mode              : d----

Can I filter the latest updated child folder form above?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This example assumes that by "latest update child folder" you want to use the LastWriteTime attribute.

Get-ChildItem "10.*" | Sort-Object -Property LastWriteTime -Descending | Select-Object -First 1
share|improve this answer
    
thank you jscott,now I got what I want.. –  pansal Jul 27 '11 at 2:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.