I wanted to create a VB login script to look at a person's "local administrator" group on a workstation and take the printed information and send it to a SQL database, from there I could create a simple select statement with an ASP page and pull the data as needed.
I know I will probably receive a lecture on how to learn VB from the ground up but unfortunately I will never consider myself a programmer because my mind does not logically work that way, hence way I am on the systems side.
I caught a code snippet from the link below but I don't have a clue on how to print the necessary information except for the following DOS commands.
So in short I want pull the contents of the local administrators group during login and push it into a database and overwrite the records each time someone logs in. Any help and patience would simply be wonderful...:-)
Unfortunately this all falls squarely on the systems side of the fence. Scripting (wmi, ad, powershell, etc) is increasingly critical for network engineers and administrators, but I digress...
What is your overall goal here? What question are you trying to answer and why? There is a good chance you can make use of off-the-shelf products (free and otherwise) if basic monitoring and reporting is what you're after.
Also, if you have a domain then this is information you could get from an AD query against the target machines, on demand...
Unfortunately, with today's economy there is less and less of a budget for IT and tools. So we need to look at building a very basic login script to look at a user's local administrator group on their workstation and place the contents of that group into a database. I commented out the first script I came across, I'm just confused on how to pull the data from the workstation and import it into the SQL table.
Yes we run an active directory domain and we would tie this login script to each user's GPO to gather the necessary data so the help desk can see who has local administrator rights on their workstation.
I ran the following and it does sort of what I need, but it gives too much data, it would be cleaner in VB and writing the data to a SQL database.
echo %computername% >> C:\test.txt
net localgroup Administrators >> C:\test.tx
'I see the variable
'The connection to the database
Set mConnection = CreateObject("ADODB.Connection")
mConnection.Open "Provider=SQLOLEDB.1;Data Source=myServerName;Initial Catalog=myDatabaseName","myUserName","myPassword"
'This is where i get confused:\ If i can extract the data with a previous script how do i import into into the table?
mConnection.Execute "INSERT INTO tbl_user_log (user_name, login_date) VALUES ('" & sUserName" & ", GetUTCDate())"
Set mConnection = Nothing
'This will write the username and current GMT date/time to a database table called tbl_user_log, with the fields user_name (VARCHAR) and login_date (DATETIME).
'If you want to retrieve values, use a recordset object such as:
I think you'll find this much less painful than trying to work with the text output of a NET command.
If you're dead set on continuing down the current path, then we get in to string parsing. I'm pretty sure you don't want to go there...
**Note I didn't explicitly test this, I just happened to have some snippets laying around. After all, I'm a programmer so most of this scripting stuff is pretty foreign to me. I'd have to ask my systems/network admin contacts for anything more complex, they do this kind of stuff all day long...