→ 🚀What's New? Join Us for the Fall Product Launch! Register Now !
‎12-20-2011 06:14 PM
‎06-14-2013 12:33 AM
‎06-14-2013 01:24 AM
nmulder wrote:
The phone number change works perfect for computers in the current domain where the script runs from. When I run the script on a user that is in a different domain I get an error about BOF and EOF are true, or the record has been deleted. I am guessing that this is because it is pulling the domain that it is running from and that user is not in it. How do I specify a different domain name to use this on those users on different domains.
Thanks,
Nick
‎04-05-2013 08:06 PM
‎04-05-2013 07:57 PM
Set WshNetwork = WScript.CreateObject("WScript.Network")
strComputer = Wscript.Arguments.Item(0)
strDescription = Inputbox("Enter Description:")
Set Obj= GetObject("winmgmts:\\" & strComputer).InstancesOf("Win32_OperatingSystem")
For Each x In Obj
x.Description = strDescription
x.Put_
Next
WScript.Quit
cscript {actionpath}ChgDesc.vbs {computer}
‎04-05-2013 07:46 PM
‎02-15-2013 07:50 PM
‎02-15-2013 10:08 PM
danscallon wrote:
I notice that this adds an x (for extension I suppose) to the phone number.
Is there a way to remove the x?
example:
I want
(970)204-5555
instead of
x(970)204-5555
' 3
objUser.Put "telephoneNumber", strExt
objUser.SetInfo
' 2
strExt = Inputbox("Enter Extension:","Enter Extension",objUser.telephoneNumber)
If strExt = "9" Then
objUser.PutEx ADS_PROPERTY_CLEAR, "telephoneNumber", 0
objUser.SetInfo
MsgBox "Extension has been cleared."
Wscript.Quit
End If
If Not adoRecord.EOF Then
On Error Resume Next
‎12-21-2011 12:18 AM
Option Explicit
Dim strUser, rootDSE, adoConnection, ldapStr, adoRecord, objUser, strExt, objExt, strMsg, choice
' Change the attribute in the 4 numbered locations and save as new VBS.
struser = WScript.Arguments(0)
Set rootDSE = GetObject("LDAP://RootDSE")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "ADs Provider"
ldapStr = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Person)(objectClass=User)(samAccountName=" & strUser & "));adspath;subtree"
Set adoRecord = adoConnection.Execute(ldapStr)
Set objUser = GetObject (adoRecord.Fields(0).Value)
' 1
strMsg = "The current extension is: " & objUser.telephoneNumber & VbCrLf & VbCrLf & _
"Do you want to change this user's extension in AD?"
choice = MsgBox(strMsg,4,"Change Extension?")
If choice = 6 Then
' 2
strExt = Inputbox("Enter Extension:","Enter Extension",objUser.telephoneNumber)
If Not adoRecord.EOF Then
On Error Resume Next
' 3
objUser.Put "telephoneNumber", "x" & strExt
objUser.SetInfo
On Error GoTo 0
End If
End If
'Set objExt = GetObject("LDAP://" & objUser.distinguishedName)
' 4
MsgBox "Extension: " & objUser.telephoneNumber,0,"User's Extension"
‎12-20-2011 10:44 PM
Option Explicit
Dim strUser, rootDSE, adoConnection, ldapStr, adoRecord, objUser, objExt, strExt
struser = WScript.Arguments(0)
strExt = Inputbox("Enter Extension Number:")
Set rootDSE = GetObject("LDAP://RootDSE")
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADSDSOObject"
adoConnection.Open "ADs Provider"
ldapStr = "<LDAP://" & rootDSE.Get("defaultNamingContext") & ">;(&(objectCategory=Person)(objectClass=User)(samAccountName=" & strUser & "));adspath;subtree"
Set adoRecord = adoConnection.Execute(ldapStr)
If Not adoRecord.EOF Then
On Error Resume Next
Set objUser = GetObject (adoRecord.Fields(0).Value)
objUser.Put "telephoneNumber", "x" & strExt
objUser.SetInfo
On Error GoTo 0
End If
Set objExt = GetObject("LDAP://" & struser)
MsgBox objExt.telephoneNumber
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now