Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Script to find all user and what PC they are logged into

Reply
 
Old 02-11-2009   #1 (permalink)
Terry


 
 

Script to find all user and what PC they are logged into

The script below works fine for a single PC but I need to get all computers
and users in the domain. Any suggestions.

On Error Resume Next
Dim System

if Wscript.Arguments.Count >0 then
sSystem=Wscript.Arguments(0)
end if

if sSystem="" then
sSystem=Inputbox("Enter a computer name to target.","WMI System Info")
if sSystem ="" then
wscript.Quit
end if
end if

Wscript.echo "Getting system information for " & sSystem & VBCRLF

Set
System=GetObject("winmgmts:{impersonationLevel=impersonate}!//"&sSystem&"/root/cimv2:Win32_ComputerSystem="&chr(34)&sSystem&chr(34))

if err.number<>0 then
wscript.echo "Error with " & sSystem
wscript.echo "(" & err.number & ") "& err.description
wscript.quit
else
sInfo="System Name:" & chr(9) & System.Caption & VBCRLF
sInfo=sInfo & "Primary Owner:" & chr(9) & System.PrimaryOwnerName & VBCRLF
sInfo=sInfo & "Current User:" & chr(9) & System.UserName & VBCRLF
sInfo=sInfo & "Current Domain:" & chr(9) & System.Domain & VBCRLF


end if

Set oWMI = GetObject("winmgmts:")
For Each bios In oWMI.InstancesOf("Win32_BIOS")
Wscript.echo "PC Serial Number: " & bios.SerialNumber
Next
MsgBox sInfo,0+64,"WMI System Info"

set System=Nothing
set sInfo=Nothing

Wscript.quit


My System SpecsSystem Spec
Old 02-11-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: Script to find all user and what PC they are logged into


"Terry" <terry@xxxxxx> wrote in message
news:FF334D11-4688-437A-8F1E-8C66F74EF070@xxxxxx
Quote:

> The script below works fine for a single PC but I need to get all
> computers and users in the domain. Any suggestions.
>
> On Error Resume Next
> Dim System
>
> if Wscript.Arguments.Count >0 then
> sSystem=Wscript.Arguments(0)
> end if
>
> if sSystem="" then
> sSystem=Inputbox("Enter a computer name to target.","WMI System Info")
> if sSystem ="" then
> wscript.Quit
> end if
> end if
>
> Wscript.echo "Getting system information for " & sSystem & VBCRLF
>
> Set
> System=GetObject("winmgmts:{impersonationLevel=impersonate}!//"&sSystem&"/root/cimv2:Win32_ComputerSystem="&chr(34)&sSystem&chr(34))
>
> if err.number<>0 then
> wscript.echo "Error with " & sSystem
> wscript.echo "(" & err.number & ") "& err.description
> wscript.quit
> else
> sInfo="System Name:" & chr(9) & System.Caption & VBCRLF
> sInfo=sInfo & "Primary Owner:" & chr(9) & System.PrimaryOwnerName & VBCRLF
> sInfo=sInfo & "Current User:" & chr(9) & System.UserName & VBCRLF
> sInfo=sInfo & "Current Domain:" & chr(9) & System.Domain & VBCRLF
>
>
> end if
>
> Set oWMI = GetObject("winmgmts:")
> For Each bios In oWMI.InstancesOf("Win32_BIOS")
> Wscript.echo "PC Serial Number: " & bios.SerialNumber
> Next
> MsgBox sInfo,0+64,"WMI System Info"
>
> set System=Nothing
> set sInfo=Nothing
>
> Wscript.quit
>
You can use the following example as a model:

http://www.rlmueller.net/Inventory.htm

This example inventories all computers in the domain. It uses ADO to
retrieve information on all computers. It pings each computer to see if it
is available, then uses WMI to connect remotely and retrieve more
information. Error trapping is used in case the computer cannot be
contacted. The results are written to an Excel spreadsheet.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Conditional execution of script for logged-on user VB Script
Windows could not find your user profile so it logged in to a temporary account.....! Vista account administration
script to find a certain info about a user PowerShell
Cant find my standard user account files when logged in as Admin?? Vista account administration
User Profile Bad if this user is not first user logged onto Vista Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46