September 2008 - Posts

VBS Script Browse For A Text File And Remove Duplicates Entries From It

 

This VBS Script will allow you to browse for a text file and will remove or strip all of the duplicates from it and then rewrite the original text file.

 

VBS Script:

 

Const ForReading = 1

Const ForWriting = 2

 

Set objDialog = CreateObject("UserAccounts.CommonDialog")

objDialog.Filter = "Text Files|*.Txt"

intResult = objDialog.ShowOpen

If intResult = 0 Then

Wscript.Quit

Else

strFileName = objDialog.FileName

End If

 

Set objDictionary = CreateObject("Scripting.Dictionary")

 

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objFile = objFSO.OpenTextFile(strFileName, ForReading)

 

Do Until objFile.AtEndOfStream

strName = objFile.ReadLine

If Not objDictionary.Exists(strName) Then

objDictionary.Add strName, strName

End If

Loop

objFile.Close

 

Set objFile = objFSO.OpenTextFile(strFileName, ForWriting)

For Each strKey in objDictionary.Keys

objFile.WriteLine strKey

Next

 

objFile.Close

MsgBox "Done"

 

 

 

Posted by dhite | with no comments
Filed under:

VBS Script To Read Machine Names From A Spreadsheet And Write Their IP Address To The Spreadsheet

 

This VBS script will allow you to read a list of machine names contained in an Excel spreadsheet called MachineList.xls. It will then write the IP address for the machine name in column A to column B.

 

To use this script the C:\ MachineList.xls file must exist with a list of machine names one per line beginning with cell A2 as cell A1 and B1 are reserved for the column header information that you can specify as you wish. For my purposes I have labeled A1 as “Machine Name” and B1 as “IP Address” and the B column of course is not populated until the script is executed.

 

Note: You can change the spreadsheet location in the script to the location and file name of your choice such as H:\MyFile.Xls or even \\ServerName\ShareName\FileName.Xls as needed.

 

VBS Script:

 

Set objExcel = CreateObject("Excel.Application")

Set objWorkbook = objExcel.Workbooks.Open("C:\MachineList.xls")

objExcel.Visible = True

i = 2

 

Do Until objExcel.Cells(i, 1).Value = ""

strComputer = objExcel.Cells(i,1)

   

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

Set colItems = objWMIService.ExecQuery("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")

For Each objItem in colItems

 

If Not IsNull(objItem.IPAddress) Then

For Each objIPAddress in objItem.IPAddress

objExcel.Cells(i,2) = objIPAddress

Next

End If

Next

i = i + 1

Loop

 

objExcel.Cells.EntireColumn.AutoFit

MsgBox "Done"

 

 

 

Posted by dhite | with no comments
Filed under:

VBS Script To Send DNS Server Record Data To Excel

 

This VBS script will write the following DNS Server information to an Excel spreadsheet: Resource machine name, IP Address, DNS server name and the Fully Qualified Domain Name or FQDN.

 

VBS Script:

 

strComputer = InputBox ("Enter DNS Server Name")

 

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 = "IP Address"

objExcel.Cells(1, 3).Value = "DNS Server"

objExcel.Cells(1, 4).Value = "FQDN"

 

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

Set colItems = objWMIService.ExecQuery("Select * From MicrosoftDNS_PTRType")

For Each objItem in colItems

 

'Extract Name From FQDN Cell 4

CompNameArray = Split(objItem.RecordData,".")

For i = LBound(CompNameArray) to UBound(CompNameArray)

objComputer = CompNameArray(0)

Next

objExcel.Cells(intRow, 1).Value = UCase(objComputer)

 

'Extract IP Address From Reverse Lookup Record OwnerName And Reverse It

IPAddArray = Split (objItem.OwnerName, ".")

For i = LBound(IPAddArray) to UBound(IPAddArray)

IPAdd = IPAddArray(3) & "." & IPAddArray(2) & "." & IPAddArray(1) & "." & IPAddArray(0)

Next

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

 

objExcel.Cells(intRow, 3).Value = objItem.DnsServerName

objExcel.Cells(intRow, 4).Value = objItem.RecordData

intRow = intRow + 1

Next

 

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"

 

 

 

Posted by dhite | with no comments
Filed under:

SQL Queries To Find Applications Installed On Machines By Group, Container, OU Or Subnet

 

Provided here you will find various SQL queries that will allow you to retrieve distinct application information such as the display name, publisher and version as listed in the Add and Remove programs applet on machines by querying a Group, Container, OU or IP Subnet.

 

# By System Group Name #

 

Select Distinct

AR.DisplayName0,

AR.Publisher0,

AR.Version0

 

From v_R_System SD

Join v_Add_Remove_Programs AR On SD.ResourceID = AR.ResourceID

Join v_RA_System_SystemGroupName GN On SD.ResourceID = GN.ResourceID

 

Where GN.System_Group_Name0 = 'DomainName\Domain Computers'

Order By AR.DisplayName0

 

# By System Container Name #

 

Select Distinct

AR.DisplayName0,

AR.Publisher0, AR.Version0

 

From v_R_System SD

Join v_Add_Remove_Programs AR On SD.ResourceID = AR.ResourceID

Join v_RA_System_SystemContainerName SC On SD.ResourceID = SC.ResourceID

 

Where SC.System_Container_Name0 = 'Domain\COMPUTERS'

Order By AR.DisplayName0

 

# By OU Name #

 

Select Distinct

AR.DisplayName0,

AR.Publisher0,

AR.Version0

 

From v_R_System SD

Join v_Add_Remove_Programs AR On SD.ResourceID = AR.ResourceID

Join v_RA_System_SystemOUName OU On SD.ResourceID = OU.ResourceID

 

Where OU.System_OU_Name0 = 'Domain.COM/DOMAIN CONTROLLERS'

Order By AR.DisplayName0

 

# By IP Subnet #

 

Select Distinct

AR.DisplayName0,

AR.Publisher0,

AR.Version0

 

From  v_R_System SD

Join v_Add_Remove_Programs AR On SD.ResourceID = AR.ResourceID

Join v_RA_System_IPSubnets SN On SD.ResourceID = SN.ResourceID

 

Where SN.IP_Subnets0 = '192.168.1.0'

Order By AR.DisplayName0

 

 

 

Posted by dhite | with no comments
Filed under:

Client Asset Information SQL Query

 

Provided here is a Client Asset Information SQL Query that will gather the following information:

 

Machine Name, Installed Site Code, Resource Domain, Account Domain, Login ID, Users Full Name, Asset Tag, Manufacturer, Model, Serial Number and Operating System

 

SQL Query:

 

Select

SD.Name0 'Machine Name',

SC.SMS_Installed_Sites0 'Site Code',

SD.Resource_Domain_OR_Workgr0 'Resource Domain',

SD.User_Domain0 'Account Domain',

SD.User_Name0 'Login ID',

UD.Full_User_Name0 'Full Name',

SE.SMBIOSAssetTag0 'Asset Tag',

CS.Manufacturer0 Manufacturer,

CS.Model0 Model,

SN.SerialNumber0 'Serial Number',

OS.Caption0 + Space(1) + OS.CsdVersion0 'Operating System',

 

Case SE.ChassisTypes0

When 1 Then 'Other'

When 2 Then 'Unknown'

When 3 Then 'Desktop'

When 4 Then 'Low Profile Desktop'

When 5 Then 'PizzaBox'

When 6 Then 'Mini-Tower'

When 7 Then 'Tower'

When 8 Then 'Portable'

When 9 Then 'Laptop'

When 10 Then 'Notebook'

When 11 Then 'Handheld Device'

When 12 Then 'Docking Station'

When 13 Then 'All-In-One'

When 14 Then 'Sub-Notebook'

When 15 Then 'Space Saving'

When 16 Then 'Lunch Box'

When 17 Then 'Main System Chassis'

When 18 Then 'Expansion Chassis'

When 19 Then 'Sub-Chassis'

When 20 Then 'Bus Expansion Chassis'

When 21 Then 'Peripheral Chassis'

When 22 Then 'Storage Chassis'

When 23 Then 'Rack-Mount Chassis'

When 24 Then 'Sealed PC'

Else 'Unknown'

End 'Chassis Type',

 

Convert(VarChar(10), HS.LastHWScan, 101) 'Hardware Scan Date'

From v_R_System SD

 

Join V_R_User UD on SD.User_Name0 = UD.User_Name0

Join V_Ra_System_SmsInstalledSites SC on SD.ResourceID = SC.ResourceID

Join V_Gs_Workstation_Status HS On SD.ResourceID = HS.ResourceID

Join V_Gs_Computer_System CS On SD.ResourceID = CS.ResourceID

Join V_Gs_System_Enclosure SE On SD.ResourceID = SE.ResourceID

Join V_Gs_Pc_Bios SN On SD.ResourceID = SN.ResourceID

Join V_Gs_Operating_System OS On SD.ResourceID = OS.ResourceID

 

Where SD.Client0 = 1

And SD.Obsolete0 = 0

 

 

 

Posted by dhite | with no comments
Filed under:

Windows 2008 Server DNS Name Does Not Exist Error 0x8007232B

 

This weekend I physically logged onto my Windows 2008 server machine and received the following error when I tried to activate the server:

 

Activation Error: Code 0x8007232b

DNS Name does not exist

 

To make a long story short my copy was an MSDN copy and when I downloaded it I cannot remember if I grabbed the product key or not, but I must have since it installed several weeks ago. Then for several weeks I remotely connected to it or managed it from my Vista machine using the admin tools until this weekend. I found the KB article Error message when you try to activate Windows Vista Enterprise, Windows Vista Business, or Windows Server 2008: "Code 0x8007232b" listed below and Method 2: Use a Multiple Activation Key worked for me and it also will work for Vista as well.

 

I might also mention that the KB article was not what I expect from the good folks at Microsoft because as far as Method 1: Set up a KMS server is concerned

The information was nearly useless unless you have a day or so to read through the docs from the Url link to try and find out how to set up the server. When you click on the supplied link it brings you to a page with the following documents none of which obviously tell you how to set up the server:

 

FINAL_Sean_Deuby_article.pdf

Volume Activation 2 0 Changes for Windows Server 2008 and Windows Vista SP1.doc

Volume Activation 2.0 Deployment Guide.doc

Volume Activation 2.0 FAQ.doc

Volume Activation 2.0 Operations Guide.doc

Volume Activation 2.0 Overview Guide.doc

Volume Activation 2.0 Planning Guide.doc

Volume Activation 2.0 Resources.doc

Volume Activation 2.0 Technical Attributes.xls

Volume Product Key Groups.doc

 

My point here is that the Url should have pointed to an article like the one below and not a page with links to documents especially nasty Pdf files which I despise any way and wonder why Microsoft is even using an application from a rival

 

How To Install KMS Server To Activate Windows Vista Business Or Enterprise

http://www.mydigitallife.info/2007/04/21/how-to-install-kms-server-to-activate-windows-vista-business-or-enterprise

 

Error message when you try to activate Windows Vista Enterprise, Windows Vista Business, or Windows Server 2008: "Code 0x8007232b"

http://support.microsoft.com/kb/929826

 

 

 

Posted by dhite | with no comments
Filed under:

Using PowerShell To Prompt For Console Credentials

 

When you first open the PowerShell console if you type Get-Credential the password dialog box will be displayed with a blank user name and password. However you can add either of the lines below to your PowerShell profile so that each time the console is opened the credentials provided will be used:

 

$Credentials = Get-Credential Domain\UserName

 

$Credentials = Get-Credential Local_UserName

 

Type $Credentials and the User name and the password (System.Security.SecureString) will be listed.

 

To see more information on the cmdlet type: Get-Help Get-Credential.

 

Tip: You can also use the –Detailed or –Full switch to get additional information such as examples for using the cmdlet.

 

Get-Help Get-Credential -Detailed.

Get-Help Get-Credential -Full.

 

 

 

Posted by dhite | with no comments
Filed under:

Jumped The Gun

 

When we say that someone jumped the gun it means that they responded to something too quickly or did not think before they responded. The term Jumped the Gun can be traced back to the sport of horse racing in the old west where a pistol or gun was fired to signal the start of the race. If the horse and rider crossed the staring line before the gun was fired they were said to have jumped the gun or stared before the gun was started or fired.

 

Today in track and field events such as foot races at schools starter or blank round firing pistols are used and if the runner crosses over the staring line before the gun is fired they too are said to have jumped the gun.

 

 

 

Posted by dhite | with no comments
Filed under:

gPXE Network Boot loader

 

gPXE is an open source network boot loader that provides a direct replacement for proprietary PXE ROMs, with many extra features such as DNS, HTTP and iSCSI and gPXE Works for Windows XP as well as Windows 2003 Server

 

http://etherboot.org

 

 

Posted by dhite | with no comments
Filed under: ,

I May Have Jumped The Gun

 

I must admit I may have jumped the gun when I decided to stop updating my “Origins” tag posts based on the weekly page views for them.

 

In less than 48 hours after posting what was to be my final Origins post entitled “That’s All She Wrote” I received more than a bakers dozen emails from folks saying how much they were going to miss them or that they wanted me to reconsider. So I had to rethink my position and decided to continue writing them just for those who were kind enough to send me an email or leave a comment on the post.

 

That’s All She Wrote

http://myitforum.com/cs2/blogs/dhite/archive/2008/09/21/that-s-all-she-wrote.aspx

 

 

 

Posted by dhite | with no comments
Filed under:

Creating A SQL Server Auto Logon Desktop Shortcut

 

In SQL Server 2005 there is no native auto logon to automatically logon however you can create a taskbar or desktop shortcut and pass the trusted connection command line switch as well as the SQL server name and database name which will accomplish the same thing as an auto logon would.

 

1. Create a new shortcut and add the following to the text box asking you to “Type the location of the item:” and then select “Next”:

 

SqlWb -E -S ServerName -d DatabaseName

 

Example:

SqlWb -E -S MySqlServer -d SMS_XXX

 

2. At the Select a Title for the Program dialog box in the text box asking you to “Type a name for this shortcut enter your SQL Server name or the Database name and select “Finish”

 

Tip: To change the default icon for the shortcut right mouse click on the icon and from the context menu select “Properties”. Then at the bottom of the dialog box select “Change Icon” and browse for a new icon using the default SqlWb.exe or browse to the %SystemRoot%\system32\SHELL32.dll and select one.

 

 

 

Posted by dhite | with no comments

ConfigMgr 2007 Component And Site System Status Available Hidden Columns

 

In ConfigMgr 2007 in the Site Status leaf the Component Status and the Site System Status leafs are provided for you to get a general overview of your site(s) current status. You can see or view the status of all the components or threads and the status for the site systems respectively in the results pane.

 

In the Component Status leaf there are two hidden columns that are not displayed by default that can be added and are the “Site Code” and the “Tally Interval”. For the Site System Status there are two available as well the “Object Type” and the “Site Code”. Follow the steps below to add the columns you wish to have displayed.

 

1. Select either the Component Status or the Site System Status leaf and right mouse click on it.

 

2. From the context menu select “View” and then select “Add/Remove Columns”.

 

3. From the Add/Remove Columns dialog box select the column(s) you want to add from the “Available columns” pane and click “Add” to add them and select “OK” when you are done.

 

Note: You can restore the defaults, move items up or down and even remove items from here as needed.

 

The newly added columns are now appended to the end of the pane and can be moved where needed by using the “Move Up” or “Move Down” buttons if you are not happy with the new view by repeating the steps above. 

 

Tips: You can also add the “Site Name” and “Tally Interval” columns to the Site Status leaf as well following the steps above.

 

The following are also available for the Status Message Queries leaf: Comments, Expression, Limit To Collection Id, Query ID and Resource Class.

 

 

 

Posted by dhite | with no comments
Filed under:

By Request VBS Script To Split Forward Space Separated Stings

 

This By Request VBS Script will provide you with an example of how to separate WMI Class stings that are separated by forward spaces (\). The user also requested a simple way to reverse the output and that script is included as well.

 

VBS Script:

 

strComputer = "."

 

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

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem in colItems

 

ArrayName = Split(objItem.UserName, "\")

MsgBox ArrayName(0) 'DomainName

MsgBox ArrayName(1) 'User Name

 

Next

 

  • To reverse the order to display the user name and then the domain name use this:

strComputer = "."

 

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

Set colItems = objWMIService.ExecQuery("Select * from Win32_ComputerSystem")

For Each objItem in colItems

 

ArrayName = Split(objItem.UserName, "\")

MsgBox ArrayName(1) 'User Name

MsgBox ArrayName(0) 'DomainName

 

Next

 

 

Posted by dhite | with no comments
Filed under:

If You Can Remember Any Of These You Are Nearing Retirement Age

 

  • Being sent to the drugstore to test vacuum tubes for the TV.
  • When a quarter was a decent allowance and another quarter a huge bonus.
  • When all of your male teachers wore neckties and female teachers had their hair done, everyday.
  • When any parent could discipline any kid, or feed him, or use him to carry groceries, and nobody, not even the kid, thought a thing of it.
  • When being sent to the principal's office was nothing compared to the fate that awaited a misbehaving student at home.
  • When girls neither dated nor kissed until late high school, if then.
  • When it took five minutes for the TV to warm up.
  • When it was considered a great privilege to be taken out to dinner at a real restaurant with your parents.
  • When Kool-Aid was the only drink for kids, other than milk and sodas.
  • When laundry detergent had free glasses, dishes or towels hidden inside the box.
  • When nearly everyone's mom was at home when the kids got there.
  • When nobody owned a purebred dog.
  • When there were two types of sneakers for girls and boys (Keds & PF Flyers), and the only time you wore them at school, was for "gym."
  • When they threatened to keep kids back a grade if they failed...and did!
  • When women were called, "Mrs. John Smith," instead of their own name.
  • When you got your windshield cleaned, oil checked, and gas pumped, without asking…for free, every time and you didn't pay for air. And you got trading stamps to boot!
  • When you'd reach into a muddy gutter for a penny.
  • When your mom wore nylons that came in two pieces.

 

 

Posted by dhite | with no comments
Filed under: