Well I finally settled on using the -Include switch, rather kludgily (is that a word?), but it seems to do what was intended.
The full detail of what I was trying to do is here - http://appsensebigot.blogspot.co.uk/2013/12/folder-actions-in-appsense-desktopnow.html- yes, shameless self-promo on a subject not many on this list may find relevant, but I need the page hits at Xmas time :-) On 12 December 2013 13:33, Michael B. Smith <[email protected]> wrote: > Must it be a single line? If not, put a Get-Item call immediately > preceding GCI. J > > > > *From:* [email protected] [mailto: > [email protected]] *On Behalf Of *James Rankin > *Sent:* Thursday, December 12, 2013 5:59 AM > *To:* [email protected] > *Subject:* Re: [NTSysADM] PowerShell is my weakness.... > > > > I guess I could probably set the source folder a level higher and then > just use the -Include switch to only operate on the target folder, but that > feels kind of kludgey.... > > > > On 12 December 2013 10:23, James Rankin <[email protected]> wrote: > > OK, this has been a useful learning process... > > Currently using the line > > Get-ChildItem -Recurse -Path $source | Sort-Object LastWriteTime > -Descending | Select-Object -First 1 | Get-Date -Format yyyyMMddhhmmssF > > which does exactly what I want - apart from one thing. It doesn't include > in the results the actual date/time stamp of the root folder itself I am > searching from (the folder specified by $source). Obviously it would be > useful to include this as if the folder's contents are changed by deleting > an item, only the change to the timestamp of the root folder will indicate > this. I know that Get-ChildItem by its very title suggests it works on the > contents only, so is there any way to include the parent folder? > > TIA, > > > > > JRR > > > > On 10 December 2013 16:12, elsalvoz <[email protected]> wrote: > > Should be as easy as this: insert a foreach to parse each file and you > should be set. > > > > PS C:\temp> $source = "c:\temp" > PS C:\temp> $d = [datetime](Get-ItemProperty -Path $source -Name > LastWriteTime).lastwritetime > PS C:\temp> $source2 = "C:\temp\7-Zip" > PS C:\temp> $d2 = [datetime](Get-ItemProperty -Path $source2 -Name > LastWriteTime).lastwritetime > PS C:\temp> Compare-Object $d $d2 > InputObject SideIndicator > ----------- ------------- > 7/31/2013 12:01:57 PM => > 12/9/2013 4:12:11 PM <= > > > > On Tue, Dec 10, 2013 at 6:59 AM, James Rankin <[email protected]> > wrote: > > Aha! > > Thanks for all the input guys. I think I may be able to continue onwards > now....although I will probably hit a snag when I try to compare the two, > knowing my luck :-) > > Cheers, > > JR > > > > On 10 December 2013 14:51, Christopher Bodnar <[email protected]> > wrote: > > get-childitem c:\temp\* |select -expandproperty lastAccessTime|get-date > -Format g > > *Christopher Bodnar* > Enterprise Architect I, Corporate Office of Technology:Enterprise > Architecture and Engineering Services > > Tel 610-807-6459 > 3900 Burgess Place, Bethlehem, PA 18017 > [email protected] > > > > * The Guardian Life Insurance Company of America* > > www.guardianlife.com > > > > > > > From: James Rankin <[email protected]> > To: [email protected] > Date: 12/10/2013 06:29 AM > > Subject: [NTSysADM] PowerShell is my weakness.... > > Sent by: [email protected] > ------------------------------ > > > > > I'm trying to compare the date/time stamps of two folders (including all > the included files and subfolders). So far, this seems to do the trick > > get-childitem c:\users\me\test\* | select -expandproperty lastaccesstime > > but the problem is it pumps out the date in a long format - how can I get > it to be a short format so I can easily compare the two? > > TIA, > > > > > -- > * James Rankin* > Technical Consultant (ACA, CCA, MCTS) > http://appsensebigot.blogspot.co.uk > > ----------------------------------------- This message, and any > attachments to it, may contain information that is privileged, > confidential, and exempt from disclosure under applicable law. If the > reader of this message is not the intended recipient, you are notified that > any use, dissemination, distribution, copying, or communication of this > message is strictly prohibited. If you have received this message in error, > please notify the sender immediately by return e-mail and delete the > message and any attachments. Thank you. > > > > > -- > *James Rankin* > Technical Consultant (ACA, CCA, MCTS) > http://appsensebigot.blogspot.co.uk > > > > > > > -- > *James Rankin* > Technical Consultant (ACA, CCA, MCTS) > http://appsensebigot.blogspot.co.uk > > > > > -- > *James Rankin* > Technical Consultant (ACA, CCA, MCTS) > http://appsensebigot.blogspot.co.uk > -- *James Rankin* ------------------------- RCL - Senior Technical Consultant (ACA, CCA, MCTS) | The Virtualization Practice Analyst - Presentation Virtualization http://appsensebigot.blogspot.co.uk
<<image001.jpg>>

