Discussion Locked

WMI script question

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hello
The following script (see below) configures address-related attributes for a user in an OU called sales, in coolcomputers.com. Anybody know how to get this to apply to all user in the sales OU, possible using wildcards or variables etc.

XXXXXXXXXXXXX WMI Script XXXXXXXXXXXXXXXXXXXX

Set objUser = GetObject _
("LDAP://cn=j smith,ou=sales,dc=coolcomputers,dc=com")

objUser.Put "streetAddress", "coolcomputer house" & _
VbCrLf & "One cool Way"
objUser.Put "l", "anyware"
objUser.Put "st", "UK"
objUser.Put "postalCode", "123 a11"
objUser.Put "c", "UK"
objUser.Put "postOfficeBox", "1234"

objUser.SetInfo

XXXXXXXXXXXXX WMI Script XXXXXXXXXXXXXXXXXXXX

4 replies

by huckleberryhound

Try this. Add what you want to 'set attributes here

Option Explicit
Dim User, UserName, oUser, OU, Count
Count = 0

Set OU = GetObject("LDAP://OU=sales,DC=coolcomputers,DC=com")
OU.Filter = Array("user")
For Each oUser In OU
UserName = oUser.samAccountName
Set User = GetObject("WinNT://TAIS/" & UserName & ",user")
Count = Count + 1
'set attributes here

oUser.SetInfo
Next
WScript.Echo ("Number of User Accounts = " & Count)
WScript.Quit(0)

by Member 34603486

It does not seem to like this line (See below)
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Set User = GetObject("WinNT://TAIS/" & UserName & ",user")
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
It gives me a network pathnot found error, Any chance you could explain this, I bow to you greater knowledge....

This discussion is closed to new replies.