Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: Powershell network drive Get-ChildItem issues

$
0
0

First, I would remove "\*.*" at the end of NETWORKPATH.

Second, are sure you have access to all the shares and all the subfolders in \\NETWORKPATH\ ?

Also, if you pipe the first part of your command to Get-Member, you will see that the property CreationTime should be a DateTime object :

Get-ChildItem NETWORKPATH -recurse -include *.xlsx | Get-Member -Name CreationTime
 
   TypeName: System.IO.FileInfo
 
Name         MemberType Definition
 
CreationTime Property   System.DateTime CreationTime {get;set;}

To make sure that your date is considered as a DateTime object, instead of a string, you can do this :

Get-ChildItem NETWORKPATH -recurse -include *.xlsx | Where-Object { $_.CreationTime -ge ("06/01/2014" -as [DateTime] ) }

One word of caution : ("06/01/2014" -as [DateTime] ) can be interpreted differently , depending on your $PSCulture.
For me, it was interpreted as 6th of January , not 1st of June, because my $PSCulture is English Ireland :

$date2 = ("06/01/2014" -as [DateTime])
$date2
 
06 January 2014 00:00:00
 
 
$PSCulture
en-IE

If you don't like this behaviour, you can do it another way :

[DateTime]$date3 = "06/01/2014"
$date3
 
01 June 2014 00:00:00

Viewing all articles
Browse latest Browse all 13067

Trending Articles