Hi,
It's easy to connect using WinNT:\\ class and add a user account and add it to the administrators group as seen below in my "create local user account code." But how does one find all the classes for doing this the WBem way?
I have found only 1 or 2 WBEM classes and I've used them to connect to a remote computer, supplying alternate username/password using the Wbem Moniker as listed in the bottom script snippet.
But once I'm connected using the wbem class, how can I do things like create and modify local accounts on the remote server as listed in the "create local user account code"
There seems to be SO LITTLE info on the WBEM classes and methods, like adding a local account. Lots on AD, and lots on using Winmgmt and impersonate, but very little out there on wbem monikers using alternate credentials and the available classes.
Anyone have any insights?
L,
S
'create local user account code begin
Dim strComputer
strComputer = "."
Dim strUsr
strUsr = i
On Error Resume Next
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strUsr)
objUser.SetPassword "pass123"
objUser.SetInfo
'create local user account code end
'================================== wbem connection conx and gets ip and mac:
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objWbemLocator.ConnectServer _
(strComputer, strNamespace)', strUserName, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
WScript.Echo objItem.MACAddress
For Each strAddress in objItem.IPAddress
WScript.Echo strAddress
Next
It's easy to connect using WinNT:\\ class and add a user account and add it to the administrators group as seen below in my "create local user account code." But how does one find all the classes for doing this the WBem way?
I have found only 1 or 2 WBEM classes and I've used them to connect to a remote computer, supplying alternate username/password using the Wbem Moniker as listed in the bottom script snippet.
But once I'm connected using the wbem class, how can I do things like create and modify local accounts on the remote server as listed in the "create local user account code"
There seems to be SO LITTLE info on the WBEM classes and methods, like adding a local account. Lots on AD, and lots on using Winmgmt and impersonate, but very little out there on wbem monikers using alternate credentials and the available classes.
Anyone have any insights?
L,
S
'create local user account code begin
Dim strComputer
strComputer = "."
Dim strUsr
strUsr = i
On Error Resume Next
Set colAccounts = GetObject("WinNT://" & strComputer & "")
Set objUser = colAccounts.Create("user", strUsr)
objUser.SetPassword "pass123"
objUser.SetInfo
'create local user account code end
'================================== wbem connection conx and gets ip and mac:
Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = objWbemLocator.ConnectServer _
(strComputer, strNamespace)', strUserName, strPassword)
objWMIService.Security_.authenticationLevel = WbemAuthenticationLevelPktPrivacy
Set colItems = objWMIService.ExecQuery _
("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
For Each objItem in colItems
WScript.Echo objItem.MACAddress
For Each strAddress in objItem.IPAddress
WScript.Echo strAddress
Next