I already have a command lined script that I use to get the logged in user of a computer name that works well. But many times my network monitor programs only return the IP address of a problem user. So then I have to do a Ping -A ip.ip.ip.ip to get the hostname so I can then run my code.
Is there a easy way in VBS to convert the IP to host name so I can then pass it onto the rest of the script.
Here is what I use now for the getuser script:
So the goal is to enter GETUSER IP.IP.IP.IP and it convert the hostname and do the lookup of the logged in user.
Thanks
Phil Gordemer
ARH Associates
Is there a easy way in VBS to convert the IP to host name so I can then pass it onto the rest of the script.
Here is what I use now for the getuser script:
Code:
On Error Resume Next
Set objArgs = WScript.Arguments
If objArgs.Count = 0 Then
MsgBox "GETUSER.VBS" & vbCRLF & _
"Gets the name of the logged in user on a computer" & vbCRLF & vbCRLF & _
"Usage: GETUSER computer1 computer2 computer3 ..." & vbCRLF
WScript.quit
End If
For i = 0 To objArgs.Count - 1
strComputer = objArgs(i)
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
If err <> 0 Then
MsgBox "Computer: " & UCase(strComputer) & " not found"
err.clear
Else
Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem",,48)
For Each objItem In colItems
If Len(objItem.UserName) > 1 Then
MsgBox "Computer: " & UCase(strComputer) & vbCRLF & "Logged in User: " & objItem.UserName & vbCRLF
Else
MsgBox "Computer: " & UCase(strComputer) & vbCRLF & "No user logged in" & vbCRLF
End If
Next
Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing
End If
Next
So the goal is to enter GETUSER IP.IP.IP.IP and it convert the hostname and do the lookup of the logged in user.
Thanks
Phil Gordemer
ARH Associates