Posted on February 29th, 2008 by thehabgroup
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject(”ADODB.Connection”)
Set objCommand = CreateObject(”ADODB.Command”)
objConnection.Provider = “ADsDSOObject”
objConnection.Open “Active Directory Provider”
Set objCommand.ActiveConnection = objConnection
Set objDSE = GetObject(”LDAP://RootD
SE”)
strDomain = objDSE.Get(”DefaultNamingContext”)
objCommand.CommandText = “SELECT adspath,Name FROM ‘LDAP://” & strDomain & “‘ ” & “WHERE objectClass=’user’ and objectcategory=’person’ and lastlogontimestamp <=’00000000000′”
objCommand.Properties(”Page Size”) = 2000
objCommand.Properties(”Timeout”) = 30
objCommand.Properties(”Searchscope”) = ADS_SCOPE_SUBTREE
objCommand.Properties(”Cache Results”) = […]
No Comments »
Filed under: vbscript, Active Directory
Posted on February 22nd, 2008 by thehabgroup
The following Vbscript will gather Ip address information from network cards:
Set objWMIService = GetObject(”winmgmts:\\”& strComputer & “\root\cimv2″)
Set colAdapters = objWMIService.ExecQuery (”SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True”)
n = 1
For Each objAdapter In colAdapters
wIELine
WriteLineBoldIE “Network Adapter Info”
wIETableHeaderStart “100″
wIERowStart
wIETableHeaderItem “Adapter”
wIETableHeaderItem “IP”
wIETableHeaderItem “Subnet”
wIETableHeaderItem “Gateway”
wIETableHeaderItem “DNS”
wIETableHeaderItem “WINS”
wIERowStop
If Not IsNull(objAdapter.IPAddress) Then
For i = 0 To UBound(objAdapter.IPAddress)
wIERowStart
If i=0 Then
wIERowItem “Adapter […]
No Comments »
Filed under: Operating System, vbscript, Network
Posted on August 28th, 2007 by thehabgroup
If you are interested in disabling the Windows product activation notices with a vbscript then the following steps maybe of interest to you:
In the root of your system drive save the following in a text file
Set objWMI = GetObject(”winmgmts:{impersonationLevel=
impersonate}!\\” & computer & “\root\cimv2″)Set objWPA = objWMI.ExecQuery(”Select * from
Win32_WindowsProductActivation”)
For Each PA in objWPA
PA.SetNotification(0)
Next
Replace computer with […]
No Comments »
Filed under: vbscript
Posted on August 22nd, 2007 by thehabgroup
To use this script you will need to enter the relevant username and domain into message boxes that prompt.
UserName = InputBox(”Enter the user’s login name that you want to unlock:”)
If UserName = “” Then
WScript.Echo “No username was given or you clicked Cancel”
WScript.Quit(1)
End If
DomainName = InputBox(”Enter the domain name in which the user account exists:”)
If […]
No Comments »
Filed under: vbscript, Active Directory
Posted on August 22nd, 2007 by thehabgroup
If you every need to shutdown all you domain computers due to a expected power outage, security breach etc. then this Vbscript should help:
On Error Resume Next
Set objNet = CreateObject(”wscript.network”)
strCurrentPC = objNet.ComputerName
‘The following section will connect to any Active Directory domain
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject(”ADODB.Connection”)
Set objCommand = CreateObject(”ADODB.Command”)
objConnection.Provider = “ADsDSOObject”
objConnection.Open “Active […]
No Comments »
Filed under: Operating System, vbscript
Posted on August 22nd, 2007 by thehabgroup
‘ This vbscript finds all active Terminal Server sessions on server HOST defined
‘ below and terminates them. Does not terminate the
‘ current session if being run remotely.
‘ If running on local host, set HOST value to “.”
HOST = “.”
‘ Get disconnected sessions and log them off
sessions = DisconnectedSessions(HOST)
For each session in sessions
TerminateWinSession HOST, sessionId
Next
‘ […]
No Comments »
Filed under: vbscript, Terminal Services
Posted on August 22nd, 2007 by thehabgroup
If you are a system administrator managing an Active Directory environment and you need to disable inactive user accoutns then the following vbscript may assist:
‘Queries AD for all WIndows domain accounts inactive for 12 weeks or more and disables these accounts
dsquery user -inactive 12 | dsmod user -disabled yes
‘Queries AD for all active directory […]
No Comments »
Filed under: vbscript
Posted on March 14th, 2007 by thehabgroup
===========================================================
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set arrComputers = GetObject _
(”LDAP://cn=computers, dc=domain, dc=local”)
arrComputers.Filter = Array(”Computer”)
For Each objItem In arrComputers
strComputer = objItem.CN
WScript.Echo
WScript.Echo “==========================================”
WScript.Echo “Computer: ” & strComputer
WScript.Echo “==========================================”
Set objWMI = GetObject(”winmgmts:\\” & strComputer & “\root\cimv2″)
WScript.Echo “Time zone is:”
Set colTZ = objWMI.ExecQuery(”select * from Win32_TimeZone”)
For Each objTZ in colTZ
Wscript.Echo vbTab & objTZ.Caption
Next
Set objWMIService = […]
No Comments »
Filed under: vbscript