#récupére dans la variable $listepc une liste d'ordinateur $listepc=get-content c:\test\pc.txt $auth=get-credential #$date permettra d'enregistrer notre fichier en intégrant la date $date = get-date -format "dd-MM-yyyy" $date1 = get-date -format "dd/MM/yy - hh:mm:ss" "analyse faite le : $date1" | out-file c:\test\analyse$date.txt "----------------------------------" | out-file c:\test\analyse$date.txt -append #pour chaque pc dans la liste on effectue un ping, si ok, on continue en allant chercher les classes wmi foreach($pc in $listepc) { write-host $pc if ((gwmi win32_pingStatus -filter("Address='" + $pc + "'")).statusCode -eq "0") { $hostpc=hostname #if($hostpc -eq $pc){ # Write-host "Analyse du pc local n'est pas possible avec -computername"} # else { write-host "Station $pc joignable, suite en cour ..." -foregroundcolor "green" $taille = gwmi win32_logicaldisk -computername $pc -credential $auth| where{$_.driveType -eq "3"} | %{$_.freeSpace, $_.size, $_.deviceID} $Libre=$taille[0]/(1024*1024*1024) $libre=[math]::round($libre,2) $tailletot=$taille[1]/(1024*1024*1024) $tailletot = [math]::round($tailletot,2) $util=$tailletot - $libre write-host $tailletot $bios = gwmi win32_bios -computername $pc -credential $auth| %{$_.version} write-host $bios "station analysé: $pc " | out-file c:\test\analyse$date.txt -append "Disque : $taille[2]" | out-file c:\test\analyse$date.txt -append " taille disque: $tailletot " | out-file c:\test\analyse$date.txt -append " espace dispo: $libre" | out-file c:\test\analyse$date.txt -append " utilisé: $util" | out-file c:\test\analyse$date.txt -append "version bios: $bios " | out-file c:\test\analyse$date.txt -append # } } else { write-host "Station $pc non joignable" -foregroundcolor "red" } }