November 2007 - Posts

VBS Scripts To Read Active Directory And Send All Computers Password Age To Excel

 

Here you will find two VBS scripts that will read Active Directory (AD) and return all of the machines and their password age (In days) and send the results to an excel spreadsheet sorted by the password age column. The first script uses the local domain and the second one prompts you to enter a domain name.

 

Reads Local Domain:

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Password Age"

 

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 objRootDSE = GetObject("LDAP://RootDSE")

 

strDNSDomain = objRootDSE.Get("DefaultNamingContext")

strBase = "<LDAP://" & strDNSDomain & ">"

strFilter = "(&(ObjectCategory=Computer))"

strAttributes = "name, distinguishedName"

strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";SubTree"

 

objCommand.CommandText = strQuery

objCommand.Properties("Page Size") = 99999

objCommand.Properties("Timeout") = 300

objCommand.Properties("Cache Results") = False

 

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF

Set objComputer = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName") & "")

dtmValue = objComputer.PasswordLastChanged

dtmDiff = Datediff("D", dtmValue, Now)

strLasttime = dtmDiff

 

objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Name").value

objExcel.Cells(intRow, 2).Value = strLasttime

objRecordSet.MoveNext

intRow = intRow + 1

loop

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("B1")

objRange.Sort objRange,1,,,,,,1

 

Msgbox "Done"

 

Prompts For Domain Name:

 

strDomain = InputBox("Enter Domain Domain")

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Machine Name"

objExcel.Cells(1, 2).Value = "Password Age"

 

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

objCommand.Properties("Page Size") = 1000

objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

 

strBase = "<LDAP://" & strDomain & ">"

strFilter = "(&(ObjectCategory=Computer))"

strAttributes = "name, distinguishedName"

strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";SubTree"

 

objCommand.CommandText = strQuery

objCommand.Properties("Page Size") = 99999

objCommand.Properties("Timeout") = 300

objCommand.Properties("Cache Results") = False

 

Set objRecordSet = objCommand.Execute

objRecordSet.MoveFirst

Do Until objRecordSet.EOF

Set objComputer = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName") & "")

dtmValue = objComputer.PasswordLastChanged

dtmDiff = Datediff("D", dtmValue, Now)

strLasttime = dtmDiff

 

objExcel.Cells(intRow, 1).Value = objRecordSet.Fields("Name").value

objExcel.Cells(intRow, 2).Value = strLasttime

objRecordSet.MoveNext

intRow = intRow + 1

loop

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("B1")

objRange.Sort objRange,1,,,,,,1

 

Msgbox "Done"

 

VBS Script To Determine When All Users From A Specified Domain Password Was Last Changed

http://myitforum.com/cs2/blogs/dhite/archive/2007/08/26/vbs-script-to-determine-when-all-users-from-a-specified-domain-password-was-last-changed.aspx

 

 

 

Posted by dhite | 1 comment(s)
Filed under:

VBS Script To Write System Restore Information To An Excel Spreadsheet

 

This VBS script will allow you to enter a remote workstation name from an input dialog box and return the machines System Restore information to an Excel spreadsheet. It will include all but the System Checkpoints which are created by the system. It will return the sequence number, the description, creation time date stamp and the event type.

 

VBS Script:

 

strComputer = InputBox ("Enter Machine Name")

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

objExcel.Cells(1, 1).Value = "Sequence Number"

objExcel.Cells(1, 2).Value = "Description"

objExcel.Cells(1, 3).Value = "Creation Time"

objExcel.Cells(1, 4).Value = "Event Type"

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\Default")

Set colItems = objWMIService.ExecQuery("Select * from SystemRestore Where Description <> 'System Checkpoint'")

For Each objItem in colItems

objExcel.Cells(intRow, 1).Value = objItem.SequenceNumber

objExcel.Cells(intRow, 2).Value = objItem.Description

objExcel.Cells(intRow, 3).Value = ConvWbemTime(objItem.CreationTime)

If objItem.EventType = 100 Then

objExcel.Cells(intRow, 4).Value = "Begin System Change"

ElseIf objItem.EventType = 101 Then

objExcel.Cells(intRow, 4).Value = "End System Change"

ElseIf objItem.EventType = 102 Then

objExcel.Cells(intRow, 4).Value = "Begin Nested System Change"

ElseIf objItem.EventType = 103 Then

objExcel.Cells(intRow, 4).Value = "End Nested System Change"

End If

 

intRow = intRow + 1

Next

 

Function ConvWbemTime(IntervalFormat)

sMonth = mid(IntervalFormat,5,2)

sDay = mid(IntervalFormat,7,2)

sYear = mid(IntervalFormat,1,4)

ConvWbemTime =  sMonth & "-" & sDay & "-" & sYear

End Function

 

objExcel.Range("A1:D1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsgBox "Done"

 

Additional Information From Microsoft:

 

“System Restore monitors system changes and saves the system state as a restore point. If a system problem develops as a result of a system change, the user can return the system to a previous state using the data from a restore point....Applications and the system can create restore points when system changes occur....System Restore does not restore user data or documents, so it will not cause users to lose their files, e-mail, browsing history, or favorites. System Restore is also made available to users in safe mode, making it easier for them to restore their computers to a state before problems occurred.”

 

 

Posted by dhite | with no comments
Filed under:

VBS Script To Verify If The Admin$ Share Exist On A Remote Machine

 

This VBS script will allow you to verify if the Admin$ share is accessible and exist on a remote machine.

 

VBS Script:

 

strComputer = InputBox ("Enter Machine Name")

 

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colShares = objWMIService.ExecQuery("Select * from Win32_Share Where Name = 'Admin$'")

 

If colShares.Count = 0 Then

MsgBox "Admin$ Does Not Exist On: " & UCase(strComputer)

Else

MsgBox "Admin$ Exist On: " &  UCase(strComputer)

End If

 

 

Posted by dhite | with no comments
Filed under:

SQL Query To List Excluded Servers With RegRead

 

This SQL query will allow you to retrieve or list the machines in the excluded Servers list for your SMS server exclusions using the extended procedure RegRead.

 

SQL Query:

 

Exec Master..Xp_RegRead

'HKEY_LOCAL_MACHINE',

'Software\Microsoft\Sms\Components\Sms_Discovery_Data_Manager',

'ExcludeServers'

 

 

Posted by dhite | with no comments
Filed under:

SQL Query To Find Specified Table Column Names

 

This script will allow you look for any specified column name from all of the user tables from within the current database object. This can be of particular interest to those wanting for example to find which SQL table holds the LastHWScan column.

 

SQL Query:

 

Set NoCount On

Declare @ColVar VarChar(25)

Set @ColVar = '%last%' -- String To Find

 

Select

SysObjects.Name 'Table Names:',

SysColumns.Name 'Column Names:'

 

From SysObjects, SysColumns, SysTypes

 

Where SysObjects.ID = SysColumns.ID

And SysColumns.xType = SysTypes.xType

And SysColumns.Name like @ColVar

 

Order by SysObjects.Name Asc

Set NoCount Off

 

Usage Examples:

 

Pattern Match

Set @ColVar = '%Last%'

Set @ColVar = '%last%time%'

 

Exact Match

Set @ColumnNames = 'Last'

 

 

Posted by dhite | with no comments
Filed under:

SMS 2003 Advanced Client Push Requirements

 

In SMS 2003 the Client Push Installation process requires the following for the client resources and the site server in order to function as expected.

 

Client Resources

 

1. File sharing must be set and enabled.

2. The ADMIN$ Administrative share must exist and be accessible.

3. The Server service must be enabled and started.

4. The Client Push Installation account must have access to the resource.

 

Site Server

 

The site server requires the creation of an administrative account (Client Push Installation Account) to use that can access the client resources with elevated privileges. This means that it needs to be a member of the domain admins group because this group is copied to all resources once they are joined to a domain by default.

 

Note: Many times this is the reason why your client resources are not installing or functioning as expected because the end user has removed the account from the machine or from the Domain Administrators group.

 

The account that you create for the Client Push Installation Account must also be specified in the Accounts tab for the “Client Push Installation” Properties.

 

 

Posted by dhite | with no comments
Filed under:

Windows 2003 Server Local And System Environment Variables

 

Local

 

Variable

Description

%ALLUSERSPROFILE%

Echoes the all Users Profile.

%APPDATA%

Echoes where application data is stored by default.

%CD%

Echoes the current working directory string.

%CMDCMDLINE%

Echoes the command line used to start the current Cmd.exe.

%LOGONSERVER%

Echoes the Domain Controller (DC) that validated the current logon session.

%PROMPT%

Echoes the command prompt settings for the current interpreter.

%USERDOMAIN%

Echoes the domain name where the user account exists.

%USERNAME%

Echoes the user name of the current logged on user.

%USERPROFILE%

Echoes the Returns the location of the profile for the current user.

 

System

 

Variable

Description

%CMDEXTVERSION%

Echoes the version number of the current Command processor’s extensions.

%COMPUTERNAME%

Echoes the name of the computer.

%COMSPEC%

Echoes the path of the Command shell exe.

%DATE%

Echoes the current date.

%ERRORLEVEL%

Echoes the last error code for the last command issued.

%HOMEDRIVE%

Echoes the current logged on users home directory drive letter.

%HOMEPATH%

Echoes the path to the current logged on users home directory.

%HOMESHARE%

Echoes the network path of  the current logged on users shared home directory.

%NUMBER_OF_PROCESSORS%

Echoes the number of processors installed.

%OS%

Echoes the Operating System name.

%PATH%

Echoes the Path contents.

%PATHEXT%

Echoes the file extensions list the operating system deems as executable.

%PROCESSOR_ARCHITECTURE%

Echoes the chip processor architecture.

%PROCESSOR_IDENTFIER%

Echoes the processors description.

%PROCESSOR_LEVEL%

Echoes the processors model number.

%PROCESSOR_REVISION%

Echoes the processors revision number.

%RANDOM%

Echoes a randomized number from 0 to 32767.

%SYSTEMDRIVE%

Echoes the System Root directory drive letter hosting the Operating System.

%SYSTEMROOT%

Echoes the Operating Systems system root directory drive letter and directory name.

%TIME%

Echoes the Operating Systems current time.

%WINDIR%

Echoes the Operating Systems drive letter and directory name.

 

 

Posted by dhite | with no comments
Filed under:

SCE 2007 Server Installation Essentials

 

To install SCE 2007 the Microsoft server that will host the application and the SQL database must have the Windows server 2003 Network Operating System (NOS) installed. If you are running Windows Server 2003 it must have Service Pack (SP) 1 or better installed. Windows Server 2003 R2 can also be used as well.

 

The SQL database must be SQL Server 2005 and cannot be in a clustered environment. The suggested SQL Server 2005 versions are the Standard and Enterprise editions however the Workgroup and Express versions are also supported. It is also suggested that SQL Server 2005 Service Pack (SP) 1 or better installed.

 

SCE 2007 also requires that the hosting server has Internet Information Server (IIS) 6.0 with Background Intelligent Transfer Service (BITS) 2.0 installed and running. You will also need to have the .NET Framework 2.0 Redistributable installed as well.

 

 

Posted by dhite | 2 comment(s)
Filed under:

PowerShell Script To Force A Local SMS 2003 Client To Rediscover It’s Site Code

This PowerShell script will force a local machine to rediscover its SMS site code.

 

PowerShell Script:

 

$smsClient = New-Object -Com Microsoft.SMS.Client

Write-Host "SMS Site Assignment: " $smsClient.ReAssignSite()

 

 

Posted by dhite | with no comments
Filed under:

Under The Weather

 

This term also is a nautical term as with most of the sayings we have today. In vessels such as large ships some people may feel discomfort or just get sea sick due to the rolling of the waves and the swaying of the ship when they are topside or on the deck. Some relief can be found if they go below deck into the bowels of the ship where the waves are not visible and the vessel does not sway or rock as much because of the way the vessel sits low in the water.

 

When people do this they are said to be under the weather because the weather or the outside is not visible and they are separated from it by the deck of the ship and are in a more stable position.

 

 

Posted by dhite | with no comments
Filed under:

Installing The SQL Server 2005 Management Pack For OpsMgr 2007

 

The SQL Server 2005 Management Pack For OpsMgr 2007 allows you to discover SQL 2005 database engines, Instances and databases as well as allows you to discover Database File and Group objects.

 

Feature Summary:

 

• Active Directory Helper Service

• Agent jobs

• Backup

• Backup Query Engine

• Clustering

• Databases and Tables

• DB availability

• DBCC

• Full Text Search

• Log Shipping

• Replication

• Replication monitoring

• SQL Server Agent

• SQL XML

• Web Assistant

 

Download the SQL Server 2000-2005 Management Pack (SQL Server 2000-2005 System Center Operations Manager2007 Management Pack.Msi) and execute the Msi to extract the contents to C:\Program Files\System Center Management Packs. This will in turn create the C:\Program Files\System Center Management Packs\SQL Server 2000-2005  Management Pack directory.

 

Open the System Center Operations Manager 2007 Operations Console and from the Administration leaf open Actions: Import Management Packs and import the management packs in the following order:

 

1. Microsoft.SQLServer.Library.mp

2. Microsoft.SQLServer.2005.Discovery.mp

3. Microsoft.SQLServer.2005.Monitoring.mp