Below is my script
$a = New-Object -comobject Excel.Application $a.visible = $True
$b = $a.Workbooks.Add() $c = $b.Worksheets.Item(1)
$c.Cells.Item(1,1) = "Organization" $c.Cells.Item(1,2) = "Name" $c.Cells.Item(1,3) = "Operating System" $c.Cells.Item(1,4) = "IP Address" $c.Cells.Item(1,5) = "MAC Address" $c.Cells.Item(1,6) = "Service Packs" $c.Cells.Item(1,7) = "System Type" $c.Cells.Item(1,8) = "Install Date" $c.Cells.Item(1,9) = "Manufacturer" $c.Cells.Item(1,10) = "Model" $c.Cells.Item(1,11) = "Service Tag" $c.Cells.Item(1,12) = "Serial Number" $c.Cells.Item(1,13) = "Number of Processors" $c.Cells.Item(1,14) = "Total Phsyical Memory (GB)" $c.Cells.Item(1,15) = "Last Reboot Time" $c.Cells.Item(1,16) = "Report Time Stamp"
$d = $c.UsedRange $d.Interior.ColorIndex = 19 $d.Font.ColorIndex = 11 $d.Font.Bold = $True
$intRow = 2
$cred = get-credential $colComputers = get-content C:\computers2.txt foreach ($strComputer in $colComputers) { $OS = gwmi -class Win32_OperatingSystem -Comp $strComputer $Computer = gwmi -class Win32_ComputerSystem -Comp $strComputer $Bios = gwmi -class Win32_BIOS -Comp $_ $IP = gwmi -class Win32_NetworkAdapterConfiguration -Comp $strComputer | where{$_.IPEnabled -eq "TRUE"}
$c.Cells.Item($intRow,1) = $OS.Organization $c.Cells.Item($intRow,2) = $strComputer.Toupper() $c.Cells.Item($intRow,3) = $OS.Caption $c.Cells.Item($intRow,4) = $IP.IPaddress $c.Cells.Item($intRow,5) = $IP.MACaddress $c.Cells.Item($intRow,6) = $OS.CSDVersion $c.Cells.Item($intRow,7) = $Computer.SystemType $c.Cells.Item($intRow,8) = [System.Management.ManagementDateTimeconverter]::ToDateTime($OS.InstallDate) $c.Cells.Item($intRow,9) = $Computer.Manufacturer $c.Cells.Item($intRow,10) = $Computer.Model $c.Cells.Item($intRow,11) = $Bios.serialnumber $c.Cells.Item($intRow,12) = $OS.SerialNumber $c.Cells.Item($intRow,13) = $Computer.NumberOfProcessors $c.Cells.Item($intRow,14) = "{0:N0}" -f ($computer.TotalPhysicalMemory/1GB) $c.Cells.Item($intRow,15) = [System.Management.ManagementDateTimeconverter]::ToDateTime($OS.LastBootUpTime)
$c.Cells.Item($intRow,16) = Get-date
$intRow = $intRow + 1 } $d.EntireColumn.AutoFit()
Got error
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.
Please help |
|