Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $result_path = "C:\Users\Prototype\Desktop\Workshop Powershell\logs\result.log"
  2.  
  3. $rep = Get-ChildItem -File -Path "C:\Users\Prototype\Desktop" -Recurse
  4.  
  5. $taille_max = 5000000
  6. $cpt = 0
  7. $total_poids = 0
  8.  
  9. if(Test-Path $result_path){
  10.     Copy-Item $result_path ($result_path + ".bak")
  11.     Remove-Item $result_path
  12.     }
  13.  
  14. Get-Date | Add-Content $result_path
  15.  
  16. foreach($file in $rep){
  17.     if($file.Length -le $taille_max){
  18.         <# Conditions pour prendre en compte les différents poids, à mettre également à la fin du code au résultat final #>
  19.    
  20.  
  21.         $file.fullname + " : " + ($file.Length / 1000000).ToString() + "Mo."| Add-Content $result_path
  22.  
  23.         $total_poids = $total_poids + $file.Length
  24.         $cpt++
  25.     }
  26. }
  27.  
  28. "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