Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Login script to get all possible details from the machine.

Posted on 2007-10-17
35
Medium Priority
?
284 Views
Last Modified: 2011-04-14
Hi,

I want a login script that can find the
Machinename
Username
Mac address
Ip address
Brand name
Service tag
and if there are any more...
All the results to be stored in a csv file..
I am sure that someone should have some scripts like these...
Regards
SHarath
0
Comment
Question by:bsharath
  • 18
  • 7
  • 5
  • +2
35 Comments
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20092944
You could do something like this:

wmic /node:%computername% computersystem
0
 
LVL 12

Expert Comment

by:StuFox100
ID: 20092958
I assume service tag - you have Dells.
Check out this script:
http://www.adminscripteditor.com/forum/printable.asp?m=7743
Cheers
Stu
0
 
LVL 11

Author Comment

by:bsharath
ID: 20092981
SteveGTR
what should i change in this?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093050
You see it dumps out a lot of information. There are a number of canned  lists for computersystems like:

wmic /node:%computername% computersystem list brief

You can type:

wmic /node:%computername% computersystem list /?

For more information.

Also, you'll want to capture this information to a common directory. You could use the username as part of the filename:

wmic /node:%computername% computersystem list brief >\\yourserver\share\directory\%username%_Info.txt
0
 
LVL 11

Author Comment

by:bsharath
ID: 20093099
i GET THIS...


C:\>wmic /node:%computername% computersystem list brief
Invalid Global Switch.

C:\>wmic /node:%computername% computersystem list /?
Invalid Global Switch.

Should i change anything
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093137
That looks good. What operating system are you running this on? Does this produce results?

wmic /node:%computername% computersystem
0
 
LVL 11

Author Comment

by:bsharath
ID: 20093170
I am running this on Windows 2003.For this code also i get the same error.
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093198
That doesn't make sense, but who knows. How about this?

wmic /node:. computersystem

Or this:

wmic /node:. cpu
0
 
LVL 11

Author Comment

by:bsharath
ID: 20093301
Haa for these i get results...I now remember that i have already used this...
I dont want this as it gets so much of data.

Any way that we can customise it to the requirement.
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093317
You can that's why I asked about this:

wmic /node:. computersystem list brief
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093333
Also, be careful what you ask for "and if there are any more..." ;)
0
 
LVL 11

Author Comment

by:bsharath
ID: 20093532
Ya this is fine but it misses the service tag,Mac address,Ip address
0
 
LVL 30

Expert Comment

by:SteveGTR
ID: 20093677
On my DELL machine that is encoded in the supportcontactdescription

wmic /node:. computersystem get supportcontactdescription

I don't see the IP address, but there are other ways to get this information.

Note, that if this task is performed when they login and they get their IP address from a DHCP server, they may not have acquired the IP address.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20093886
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.

C:\Documents and Settings\sharathr>wmic /node:. computersystem get supportcontactdescription
SupportContactDescription


{"For Support and Requests for External Service", "", "blah.", "blah,", "Ontario
, blah", "Phone: blah", "Email: blah", "Website: blah", "To Serve is our Pleasure :-)"}
0
 
LVL 12

Expert Comment

by:StuFox100
ID: 20107356
Try this script
Cheers
Stu

Set fso = CreateObject("Scripting.FileSystemObject")

' create output file
Set Output_FIle = fso.CreateTextFile("output.txt", True)

Set objWshShell = CreateObject("WScript.Shell")

' Get computer name
strComputerName = objWshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
out = strComputerName

' set up WMI
Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

' get network stuff
Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems
      out = out & "," & objItem.MACAddress
      out = out & "," & objitem.IPAddress(0)
Next

' get Service Tag
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
      out = out & "," & objSMBIOS.SerialNumber
Next  

' Get model
set colItems2 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
For Each objItem2 in colItems2
      out = out & "," & objItem2.Model
Next

output_file.writeline out

0
 
LVL 11

Author Comment

by:bsharath
ID: 20107416
StuFox100

Excellent just what i wanted.

If i put this as a login script then will it go on writing the output file every time the machine logs in.Any way to just write once...
0
 
LVL 3

Expert Comment

by:elissaqp
ID: 20113695
add the script as a scheduled task.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20113741
Hi,

>>add the script as a scheduled task.
Sorry could not understand...

If scheduled task will it write only once...?
0
 
LVL 12

Expert Comment

by:StuFox100
ID: 20116548
I changed it a bit. This generates the filename as "computername.txt".
It will only write it once.
Cheers
Stu

Set fso = CreateObject("Scripting.FileSystemObject")

Set objWshShell = CreateObject("WScript.Shell")

' Get computer name
strComputerName = objWshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
out = strComputerName

'setfile name
file_name = strComputerName & ".txt"

if fso.fileexists (file_name) = false then
      ' create output file
      Set Output_FIle = fso.CreateTextFile(file_name, True)

      ' set up WMI
      Set objWMIService = GetObject("winmgmts:\\.\root\cimv2")

      ' get network stuff
      Set colItems = objWMIService.ExecQuery ("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")

      For Each objItem in colItems
            out = out & "," & objItem.MACAddress
            out = out & "," & objitem.IPAddress(0)
      Next

      ' get Service Tag
      Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_SystemEnclosure")
      For Each objSMBIOS in colSMBIOS
            out = out & "," & objSMBIOS.SerialNumber
      Next  

      ' Get model
      set colItems2 = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
      For Each objItem2 in colItems2
            out = out & "," & objItem2.Model
      Next
      
      output_file.writeline out

End if
0
 
LVL 11

Author Comment

by:bsharath
ID: 20122573
Hi,

Will the script create different files for each machine.Can the script update all in a single results file.
0
 
LVL 12

Expert Comment

by:StuFox100
ID: 20122596
yep - change

'setfile name
file_name = strComputerName & ".txt"

to
'setfile name
file_name = "\\fileshare\share\filename.txt"
Cheers
Stu

0
 
LVL 11

Author Comment

by:bsharath
ID: 20122743
Hi,

Should i use this script as a Computer Startup script or User login script...I tried in both places but did not record in the file
0
 
LVL 11

Author Comment

by:bsharath
ID: 20122770
0
 
LVL 12

Expert Comment

by:StuFox100
ID: 20130732
Computer startup is where we use ours.

Make sure the share allows domain computers write access and the to file location as well.

Cheers
Stu
0
 
LVL 11

Author Comment

by:bsharath
ID: 20136486
StuFox100

Some problem is there..Only 1 machines data is being collected to the filename.txt

I have checked with many machines and have manually executed the vbs file.Only the 1st entry is there...
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20213926
Try changing
Set Output_FIle = fso.CreateTextFile(file_name, True)
to
Const intForAppending = 8
Set Output_FIle = fso.OpenTextFile(file_name, intForAppending, True)

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20213952
No Rob still just get 1 machines data.

I have put this script in the Computer Configuration "Startup"

Is that right.But still does not work.Only 1st executed data is stored in the file
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20213957
As a computer configuration script, you'll have to change
file_name = "\\fileshare\share\filename.txt"
to
file_name = "\\dcserver\netlogon\filename.txt"

so it writes to the NetLogon share on a domain controller.  StartUp Scripts run under the System account, and that acount only has access to the NetLogon share.

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20214191
Rob i tried both ways but still just get 1 machines data updated....
Do you have any other script that can do thi...
0
 
LVL 11

Author Comment

by:bsharath
ID: 20229900
Rob i tried both ways but still just get 1 machines data updated....
Do you have any other script that can do this...
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 20247180
Sharath, I just saw that this line exists:
if fso.fileexists (file_name) = false then

which means it won't even open the file if it already exists.  Please comment out that line, and the End If down the bottom, and try again.

Regards,

Rob.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20250158
Rob after commenting the lines what happens is .The no of times i execute the vbs file so many entries
come to the txt file.Previously no matter how many times i execute the vbs file only one entry used to be entered in the txt file.

So there is some other issue in the vbs that just takes one machines entries to the file.
0
 
LVL 11

Author Comment

by:bsharath
ID: 20259580
Rob regarding this post do you have any other script that i can use as a logon script or get info from a list of machines which i have in a txt file.
Here are some posts which i wanted to keep you posted for help.

http://www.experts-exchange.com/Programming/Languages/Q_22952821.html
http://www.experts-exchange.com/Programming/Languages/Q_22936422.html
http://www.experts-exchange.com/Programming/Languages/Scripting/Q_22908282.html
http://www.experts-exchange.com/Microsoft/Applications/Q_22893275.html
0
 
LVL 65

Expert Comment

by:RobSampson
ID: 20294728
Sharath, in your second last post you mentioned that it does append the data to the text file.  Isn't that what you wanted this script to do?

Regards,

Rob.
0
 
LVL 11

Author Closing Comment

by:bsharath
ID: 31408199
Thanks a lot Rob...After i rechecked and commented the line it worked...
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of modules and packages in Python. Every Python file is a module, ending in the suffix: .py: Modules are a collection of functions and variables.: Packages are a collection of modules.: Module functions and variables are accessed us…
Suggested Courses

580 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