Vbs Script to Retrieve Name of Ads User
Hello,
I am trying to make a vbs script which gives me the first and last name of my AD User that runs the scripts Here is a part of the code:
Code:
Select All
Set Root = GetObject("LDAP://RootDSE")
DomainPath = Root.Get("DefaultNamingContext")
Set Domain = GetObject("LDAP://" & DomainPath)
Set objUse = GetObject("LDAP://OU=OU-Utilisateurs," & DomainPath)
WScript.Echo "First Name: " & objUse.givenName
But when I run It nothing happens, I have full test without ever seeing the name or surname , In my OU Users OU-I "sub" or "style of Students, Teachers, Admin please Give me Proper Suggestions and Code that you might Have use to Achieve the Following results.
Re: Vbs Script to Retrieve Name of Ads User
Hello , You Can Checkout the Following
Code:
Set objWMISvc = GetObject( "winmgmts:\\.\root\cimv2" )
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )
For Each objItem in colItems
strUserName = objItem.UserName
WScript.Echo "User Name: " & strUserName
Next
it Might Help You
Re: Vbs Script to Retrieve Name of Ads User
Hello , You Can the command "net user", it Will tell you the Same Things .You can use the net user command to create and modify user accounts on omputers. When you use this command without command-line switches, the user accounts for the computer are listed. The user account information is stored in the user accounts database. This command works only on servers.
Re: Vbs Script to Retrieve Name of Ads User
Hello , You might want to Check these Code also if it help you
Code:
Public Function UserName() As String
On Error Resume Next
Dim oSysInfo As New ActiveDs.WinNTSystemInfo
UserName = oSysInfo.UserName
Set oSysInfo = Nothing
End Function