Sign in to follow this  
Followers 0
iceberg

PC info

3 posts in this topic

Can someone please help me out here....why doesn't my script work?

Thanks.

$Serverpath = (@DesktopDir)
$AuditFile = ($Serverpath & "\" & @ComputerName & ".TXT")
$strComputer = "."
$SN = ""

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem", 48)
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct", 48)

For $objItem in $colItems
    $SN = $objItem.IdentifyingNumber
    FileWrite($AuditFile, "ComputerName: " & @ComputerName)
    FileWrite($AuditFile, "Brand: " & $objItem.Manufacturer)
    FileWrite($AuditFile, "Model: " & $objItem.Model)
    FileWrite($AuditFile, "SN: " & $SN)
Next

MsgBox(0, "End", "Done")

mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites



Can someone please help me out here....why doesn't my script work?

Thanks.

$Serverpath = (@DesktopDir)
$AuditFile = ($Serverpath & "\" & @ComputerName & ".TXT")
$strComputer = "."
$SN = ""

$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystem", 48)
$colItems = $objWMIService.ExecQuery("Select * from Win32_ComputerSystemProduct", 48)

For $objItem in $colItems
    $SN = $objItem.IdentifyingNumber
    FileWrite($AuditFile, "ComputerName: " & @ComputerName)
    FileWrite($AuditFile, "Brand: " & $objItem.Manufacturer)
    FileWrite($AuditFile, "Model: " & $objItem.Model)
    FileWrite($AuditFile, "SN: " & $SN)
Next

MsgBox(0, "End", "Done")
Hi,

Better try this

Local $objItem, $colSystem, $colProduct, $bitOr = BitOR(0x10,0x20)
$Serverpath = (@DesktopDir)
$AuditFile = FileOpen("c:\temp\" & @ComputerName & ".TXT",2); erase previous file

If $AuditFile Then
    $strComputer = @Computername
    $SN = ""

    $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")
    $colSystem = $objWMIService.ExecQuery("Select Name, Manufacturer, Model from Win32_ComputerSystem WHERE Name='" & $strComputer & "'", "WQL", $bitOr)

    For $objItem in $colSystem
        FileWrite($AuditFile, "ComputerName: " & @ComputerName & @CRLF)
        FileWrite($AuditFile, "Brand: " & $objItem.Manufacturer & @CRLF)
        FileWrite($AuditFile, "Model: " & $objItem.Model & @CRLF)
    Next

        $colProduct = $objWMIService.ExecQuery("Select Caption, Name, IdentifyingNumber from Win32_ComputerSystemProduct" , "WQL", $bitOr)
    For $objItem in $colProduct
        FileWrite($AuditFile, "SN: " & $objItem.IdentifyingNumber)
    Next

    MsgBox(0, "End", "Done")
Else
    MsgBox(0, "Error", "Unable to create/open file")
    
EndIf

WHERE Name = in first query is optional, but in case you would try it on remote computers...

Joe


registry victim

Share this post


Link to post
Share on other sites

thanks joell!

works great....just what I wanted.


mouse not found....scroll any mouse to continue.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0