title: Unable to get PowerShell code to work
body: <p>I am trying to run a script from my Active Directory host to the other hosts on the network that will pull device info for each of the hosts.</p>
  
  <p>The code I am using is:</p>
  
  <pre><code># Exports Local System Information to CSV
  # Run this PowerShelll script at log on to collect PC information to a CSV file on a network share
  # Thom McKiernan 28/08/2014
  
  #Get hostnames
  #$Computers = Get-Content ("C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\ComputerListAug2015.txt") -ErrorAction SilentlyContinue
  
  foreach ($computer in Get-Content "C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\ComputerListAug2015.txt")
  {
  
  # Collect the info from WMI
  $computerSystem = get-wmiobject Win32_ComputerSystem -Computer $computer.$deviceinfile
  $computerBIOS = get-wmiobject Win32_BIOS -Computer $computer.$deviceinfile
  $computerOS = get-wmiobject Win32_OperatingSystem -Computer $computer.$deviceinfile
  $computerCPU = get-wmiobject Win32_Processor -Computer $computer.$deviceinfile
  $computerHDD = Get-WmiObject Win32_LogicalDisk -ComputerName $computer.$deviceinfile -Filter drivetype=3
  $macAddress = Get-WmiObject win32_networkadapterconfiguration -Computer $computer.$deviceinfile -Filter "IpEnabled = TRUE"
  
  #Build the CSV file
  $csvObject = New-Object PSObject -property @{
      "PCName" = $computerSystem.Name
      "Manufacturer" = $computerSystem.Manufacturer
      "Model" = $computerSystem.Model
      "SerialNumber" = $computerBIOS.SerialNumber
      "RAM" = "{0:N2}" -f ($computerSystem.TotalPhysicalMemory/1GB) + "GB"
      "HDDSize" = "{0:N2}" -f ($computerHDD.Size/1GB) + "GB"
      "HDDFree" = "{0:P2}" -f ($computerHDD.FreeSpace/$computerHDD.Size) + "GB"
      "CPU" = $computerCPU.Name
      "OS" = $computerOS.caption
      "SP" = $computerOS.ServicePackMajorVersion
      "User" = $computerSystem.UserName
      "BootTime" = $computerOS.ConvertToDateTime($computerOS.LastBootUpTime)
      "MACAddress" = $macAddress.MacAddress
      } 
  
  #Export the fields you want from above in the specified order
  $csvObject | Select PCName, Maufacturer, Model, SerialNumber, RAM, HDDSize, HDDFree, CPU, OS, SP, User, BootTime, MACAddress | Export-Csv 'system-info.csv' -NoTypeInformation -Append
  
  }
  
  # Open CSV file for review (leave this line out when deploying)
  notepad system-info.csv
  </code></pre>
  
  <p>However, I am continuously getting the following error:</p>
  
  <blockquote>
    <p>Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.</p>
  </blockquote>
  
  <p>I have tried to set up the txt file as just computer names (exported from Active Directory) and I have tried to append each name with ".domain.com" and neither have worked.</p>
  
  <p>I tried to have just my own device in the list, and no error occurred, but there was no output either. It was as if it didn't run when using "powershell -noexit .\ComputerDetails.ps1" but when I just run the script by right-clicking on it I can see the errors fly by, and an error from Notepad saying the file does not exist.</p>
  
  <p>I have tried to google this issue, and found countless resources, that do not seem to help get rid of this error.</p>
  
  <p>Full list of errors recieved:</p>
  
  <pre><code>Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:12 char:63
  + $computerSystem = get-wmiobject Win32_ComputerSystem -Computer &lt;&lt;&lt;&lt;  $compute
  r.$deviceinfile
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:13 char:51
  + $computerBIOS = get-wmiobject Win32_BIOS -Computer &lt;&lt;&lt;&lt;  $computer.$deviceinf
  ile
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:14 char:60
  + $computerOS = get-wmiobject Win32_OperatingSystem -Computer &lt;&lt;&lt;&lt;  $computer.$
  deviceinfile
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:15 char:55
  + $computerCPU = get-wmiobject Win32_Processor -Computer &lt;&lt;&lt;&lt;  $computer.$devic
  einfile
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:16 char:61
  + $computerHDD = Get-WmiObject Win32_LogicalDisk -ComputerName &lt;&lt;&lt;&lt;  $computer.
  $deviceinfile -Filter drivetype=3
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Get-WmiObject : Cannot validate argument on parameter 'ComputerName'. The argum
  ent is null or empty. Supply an argument that is not null or empty and then try
   the command again.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:17 char:72
  + $macAddress = Get-WmiObject win32_networkadapterconfiguration -Computer &lt;&lt;&lt;&lt;
   $computer.$deviceinfile -Filter "IpEnabled = TRUE"
      + CategoryInfo          : InvalidData: (:) [Get-WmiObject], ParameterBindi
     ngValidationException
      + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Power
     Shell.Commands.GetWmiObjectCommand
  
  Attempted to divide by zero.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:27 char:53
  +     "HDDFree" = "{0:P2}" -f ($computerHDD.FreeSpace/ &lt;&lt;&lt;&lt; $computerHDD.Size)
  + "GB"
      + CategoryInfo          : NotSpecified: (:) [], RuntimeException
      + FullyQualifiedErrorId : RuntimeException
  
  Export-Csv : A parameter cannot be found that matches parameter name 'Append'.
  At C:\Users\Administrator.ESP\Documents\SoftwareAuditing\ComputerDetails\Comput
  erDetails.ps1:37 char:183
  + $csvObject | Select PCName, Maufacturer, Model, SerialNumber, RAM, HDDSize, H
  DDFree, CPU, OS, SP, User, BootTime, MACAddress | Export-Csv 'system-info.csv'
  -NoTypeInformation -Append &lt;&lt;&lt;&lt;
      + CategoryInfo          : InvalidArgument: (:) [Export-Csv], ParameterBind
     ingException
      + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Comm
     ands.ExportCsvCommand
  </code></pre>