Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


NEED HELP WITH powershell

NEED HELP WITH powershell

NEED HELP WITH powershell

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

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

RE: NEED HELP WITH powershell

Shouldn't this line:


$Bios = gwmi -class Win32_BIOS -Comp $_
be this?


$Bios = gwmi -class Win32_BIOS -Comp $strComputer

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close