Link to home
Start Free TrialLog in
Avatar of WeTi
WeTi

asked on

Pwoershell to list creationtime of gci.

Dear expert

I need help with the code below, now that I got $server.name and $server.path using the import-csv, I also need the CreationTime of the file.
I tried sevral code but it didnt work as i wanted, please help.

Thanks

$servers = Import-Csv -Path C:\Scripts\serverlist.csv

$result= ForEach ($server in $servers) {
$count = (Get-ChildItem -Path $server.Path -ErrorAction SilentlyContinue | (get-item $server).LastWriteTime |Measure-Object).Count
If ($count -gt 0) {
		"$($count) Files in '$($server.Path)'; This is for $($server.DisplayName); The last write time is: $($lastWriteTime = (Get-Item $server).LastWriteTime)"
	}
} 
$result

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of WeTi
WeTi

ASKER

as great as ever, thx