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...