Quantcast
Channel: PowerShell
Viewing all articles
Browse latest Browse all 15370

Create file from forach when file counts greater than 250

$
0
0
Text
$fso = New-Object -com "Scripting.FileSystemObject"$f = $fso.GetFolder("D:\websphere\logs")


I have a directory called D:\websphere\logs, and D:\websphere\logs has many of sub-directories. I need to count the files under each directory, and write to a .txt file when the file count of each sub-folder is greater than 250.

Text
foreach ($folder in $f.subfolders) { Write-Host $((get-childitem $folder.path).count)','$folder.Path New-Object -TypeName PSObject -Property @{ SystemName = $((get-childitem $folder.path).count) Reachable = $folder.Path } | Export-Csv -path D:\websphere\output.txt -Append $data = import-csv -path .\test.txt -header close, server$data | where-object{$_.close -gt 250} |format-table -autosize

The count is working fine, but I can't make the next piece (write file count to a .txt file when the file count of each...


Viewing all articles
Browse latest Browse all 15370

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>