title: powershell computer information script
body: <p>I need to create a powershell script you can double-click on (64-bit computer) and it will output to a .txt file in the same location as the powershell script to generate information on:</p>
  
  <ul>
  <li>Computer name/model/serial no.</li>
  <li>C drive size/available disk space on the C drive</li>
  <li>Which version operating system the computer is running</li>
  <li>Who is currently logged onto the computer</li>
  </ul>
  
  <p>So far (but it's not quite working) I've got:</p>
  
  <pre><code>$computerSystem = get-wmiobject Win32_ComputerSystem
  $computerOS = get-wmiobject Win32_OperatingSystem
  $computerHDD = Get-WmiObject Win32_LogicalDisk -Filter drivetype=3
  
  $txtObject = New-Object PSObject -property @{
      'PCName' = $computerSystem.Name
      'Model' = $computerSystem.Model
      'SerialNumber' = $computerBIOS.SerialNumber
      'HDDSize' = "{0:N2}" -f ($computerHDD.Size/1GB)
      'HDDFree' = "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size)
      'OS' = $computerOS.caption
      'SP' = $computerOS.ServicePackMajorVersion
      'User' = $computerSystem.UserName
      } 
  
  $txtObject | Select PCName, Model, SerialNumber, HDDSize, HDDFree, OS, SP, User | Get-Process | Out-File 'system-info.txt' -NoTypeInformation -Append
  </code></pre>