i have following script:
get-childitem $rootpath -recurse | where-object {$_.psiscontainer} | where-object {(get-childitem $_.fullname | where-object {!$_.psiscontainer}| measure-object | select-object -expandproperty count) -gt 0} | foreach-object{ $files = get-childitem $_.fullname $props = @{ path = $_.fullname size = "{0:n0}" -f (($files | where-object {!$_.psiscontainer} | measure-object -sum length | select-object -expandproperty sum)) count = $files | measure-object | select-object -expandproperty count } if ($files.extension -match "l\d\d"){ # these special files , assuming alone in directory # change path $props.path = $files | select-object -first 1 | select-object -expandproperty fullname } new-object -typename pscustomobject -property $props } | select path,size,count how can write output textfile instead of console?
forward out-file. example:
get-childitem ... <skipped> } | select path,size,count | out-file "files.txt"
Comments
Post a Comment