Solved

Remote WMIC for Dell Service Tag

Posted on 2011-02-23
5
1,964 Views
Last Modified: 2016-02-23
Having some issues.

@echo off
SYSTEMINFO /S “servername” /U “Doamin”\”username” /P “password” /FO CSV >> "C:\My\Desktop\INFO.csv"

Works like a champ. But it does not give me the Dell Service Tag that I need.

@echo off
wmic csproduct get name,vendor,identifyingNumber >> "C:\My\Desktop\Service_Tag_INFO.csv"

works locally, with identifyingNumber being the service tag, but I cannot get it to work remotely.

I need to combine these two and so far, nada. Ultimately I guess,  I just need to get the second one to work.

I have tried;

wmic /node:”Machine-Name” csproduct get name,vendor,identifyingNumber >> "C:\My\Desktop\Service_Tag_INFO.csv"

with no luck. I get “Invalid Global Switch” I certainly plead ignorance to all of the subtleties of using WMIC, so any thoughts would be appreciated.

I am trying to run this from a Windows 7 Professional box to multiple Server 2008R2 boxes. I have turned on WMI through the firewall on the one test server I am trying to hit. As well as in the Inbound and Outbound rules.
0
Comment
Question by:CaineMarko
5 Comments
 
LVL 11

Expert Comment

by:yelbaglf
Comment Utility
You could try something like this, which uses the Win32_SystemEnclosure Class to pull the SerialNumber property.

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber
Next

Open in new window

0
 
LVL 7

Expert Comment

by:TechnoChat
Comment Utility
Try this script, you can get service tag of multiple system. This script written by Jim Cameron.


Details:
' Dell-ServiceTag
'
' Purpose: Obtain the Dell service tag from a Dell computer or computers.
'
' Version: 1.0
' Created on: 2008-01-10
' Last updated: 2008-01-10
'
' Created By: Jim Cameron
'
' Download URL:
' http://support.moonpoint.com/downloads/computer_languages/VBScript/Dell-ServiceTag.vbs
'
' Note: Based on a script written by LazyNetworkAdmin
' (http://lazynetworkadmin.com/), which is provided at
' http://lazynetworkadmin.com/content/view/13/6/
'

' Usage: From a command prompt, use "cscript /nologo dell-servicetag.vbs
' <computername1> <computername2>
'
' Examples:
'
' 1. Query computer on which the script is run:
'
' cscript /nologo dell-servicetag.vbs .  
'
' 2. Query multiple computers named a, b, c
'
' cscript /nologo dell-servicetag.vbs a b c
'
' Output:
'
' Computer: a Dell Service Tag: ZRKF461
' Computer: b Dell Service Tag: ZZ89M81
' Computer: c Dell Service Tag: EYCNH41
'
' -------------------------------------------------------------------------- '

' Dell-ServiceTag
'
' Purpose: Obtain the Dell service tag from a Dell computer or computers.
' 
' Version: 1.0
' Created on: 2008-01-10
' Last updated: 2008-01-10
'
' Created By: Jim Cameron
'
' Download URL: 
' http://support.moonpoint.com/downloads/computer_languages/VBScript/Dell-ServiceTag.vbs
'
' Note: Based on a script written by LazyNetworkAdmin 
' (http://lazynetworkadmin.com/), which is provided at
' http://lazynetworkadmin.com/content/view/13/6/
'

' Usage: From a command prompt, use "cscript /nologo dell-servicetag.vbs
' <computername1> <computername2>
'
' Examples:
' 
' 1. Query computer on which the script is run:
'
' cscript /nologo dell-servicetag.vbs .  
' 
' 2. Query multiple computers named a, b, c
'
' cscript /nologo dell-servicetag.vbs a b c
'
' Output:
'
' Computer: a Dell Service Tag: ZRKF461
' Computer: b Dell Service Tag: ZZ89M81
' Computer: c Dell Service Tag: EYCNH41
' 
' -------------------------------------------------------------------------- '

strVersion = "1.0"

' If the system doesn't exist or is inaccessible don't display a window
' with error code in it.
On error resume next

If Wscript.Arguments.Count = 0 Then
   ShowUsage()
Else
    Dim arrComputers()
    For i = 0 to Wscript.Arguments.Count - 1
	Redim Preserve arrComputers(i)
	arrComputers(i) = Wscript.Arguments(i)
    Next
End If
    
For Each strComputer in arrComputers
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colComputer = objWMIservice.ExecQuery("Select * from Win32_BIOS",,48)
    For Each objComputer in colComputer
	If Err.Number=0 Then
           Wscript.Echo "Computer: " & strComputer & " " & _
           "Dell Service Tag: " & objComputer.serialnumber
        Else
            WScript.Echo strComputer & " <system inaccessible>"
            Err.Clear
        End If 
    Next      
Next

Wscript.Quit

sub ShowUsage()
   WScript.Echo "Dell-ServiceTag " & strVersion & vbcrlf & _
   vbcrlf & _
   "Display the service tag for a Dell computer or computers." & vbcrlf & _
   vbcrlf & _
   "Usage: From a command prompt, use cscript /nologo " & _
   "dell-servicetag.vbs computername1" & vbcrl & _
   " computername2" & vbcrlf & _
   vbcrlf & _
   "Examples:" & vbcrlf & _
   vbcrlf & _ 
   " 1. Query computer on which the script is run (a period can be " & vbcrlf _ 
   & "    used in lieu of the name of the current computer):" & vbcrlf & _
   vbcrlf & _
   "    cscript /nologo dell-servicetag.vbs ." & vbcrlf & _  
   vbcrlf & _
   " 2. Query multiple computers named a, b, c:" & vbcrlf & _
   vbcrlf & _
   "    cscript /nologo dell-servicetag.vbs a b c"
   WScript.Quit
End Sub

Open in new window

0
 
LVL 11

Accepted Solution

by:
yelbaglf earned 500 total points
Comment Utility
You could also do something like this, which would allow you to run this against any number of PC's or Server's, etc. and write the results to a log file.

On Error Resume Next
Const svcTag_LOG = "\\Path_To_Log\svcTag_LOG.txt"
Const ForReading = 1

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
    ("\\Path_To_ServerList\servers.txt", ForReading)

strText = objTextFile.ReadAll
objTextFile.Close

arrComputers = Split(strText, vbCrLf)

For Each strComputer in arrComputers
    	'Wscript.Echo strComputer
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery _
("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
'Wscript.Echo "Dell Service Tag: " & objSMBIOS.SerialNumber
Set objLogFile = objFSO.CreateTextFile(svcTag_LOG, 2)
objLogFile.WriteLine ("Dell Service Tag for " & strComputer & " is " & objSMBIOS.SerialNumber)
Next
Next

Open in new window

0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
Thanks a lot! Work great!
0
 

Expert Comment

by:Mad Atterz
Comment Utility
Thanks, that works a treat. Is there a way of also reporting who the current logged on user is aswell?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was supporting a handful of Windows 2008 (non-R2) 2 node clusters with shared quorum disks. Some had SQL 2008 installed and some were just a vendor application that we supported. For the purposes of this article it doesn’t really matter which so w…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now