Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

very simple yet doesnt work:)

$
0
0

could it be lack of coffee or something:)

I did this before in different ways but now cant get it to work

I just to check the size of a folder or  a sum of files inside a folder(logs)

seems very straight forward so:

$Servers="server1","server2"

$daystocheck=(get-date).adddays(-1)

$location="\\$server\c$\inetpub\logs\LogFiles\W3SVC1\"

Foreach($serverin$servers)

{$server;(gci$location-filter*.log|?{$_.lastwritetime -lt$daystocheck}|Measure-Objectlength-Sum).sum/1mb}

seems I am only getting:

server1

size1

server2

size1

instead of :

server1

size1

server2

size2

what am I missing here?

(I am sure its stupid mistake like it always is:))


Viewing all articles
Browse latest Browse all 6937

Trending Articles