Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $result_path = "C:\Users\Prototype\Desktop\Workshop Powershell\logs\result.log"
- $rep = Get-ChildItem -File -Path "C:\Users\Prototype\Desktop" -Recurse
- $taille_max = 5000000
- $cpt = 0
- $total_poids = 0
- if(Test-Path $result_path){
- Copy-Item $result_path ($result_path + ".bak")
- Remove-Item $result_path
- }
- Get-Date | Add-Content $result_path
- foreach($file in $rep){
- if($file.Length -le $taille_max){
- <# Conditions pour prendre en compte les différents poids, à mettre également à la fin du code au résultat final #>
- $file.fullname + " : " + ($file.Length / 1000000).ToString() + "Mo."| Add-Content $result_path
- $total_poids = $total_poids + $file.Length
- $cpt++
- }
- }
- "Au total, " + $cpt.ToString() + " fichiers au dessus de " + ($taille_max/1000000).ToString() +"Mo ont été trouvés pour un total de " + ($total_poids / 1000000).ToString() + "Mo." | Add-Content $result_path
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement