PowerShell: Verfügbaren Hauptspeicher (RAM) für mehrere PCs ermitteln

URL dieses Beitrags: http://blog.stefan-macke.com/2008/11/24/powershell-verfuegbaren-hauptspeicher-ram-fuer-mehrere-pcs-ermitteln/

Heute brauchte ich eine Liste all unserer PCs mit ihrem verfügbaren/installierten Hauptspeicher. Nichts leichter als das, denkt der PowerShell-Benutzer:

  1. # Checks every computer in the given array for its amount of installed RAM
  2. # —————————————————————————- #
  3.  
  4. $pcs = @("pc1", "pc2");
  5.  
  6. foreach ($pc in $pcs)
  7. {
  8.         $pcInfo = gwmi win32_computersystem -computername $pc;
  9.         if ($pcInfo -ne $null)
  10.         {
  11.                 write-host ($pc + ": Installed RAM " + [Math]::round($pcInfo.totalphysicalmemory / (1024 * 1024), 0) + " MB") -foregroundcolor "green";
  12.         }
  13.         else
  14.         {
  15.                 write-host ($pc + ": Could not read computer information") -foregroundcolor "magenta";
  16.         }
  17. }

Mit meinen eigenen Funktionen kann ich dann das Array sogar noch automatisch aus dem Active Directory füllen lassen und vor dem Ermitteln der PC-Informationen prüfen, ob der PC online ist.

Einen Kommentar schreiben

XHTML: Diese Tags sind erlaubt: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>