May 2008 - Posts

VBS Script To Delete A Directory Folder On A Local Machine

 

This VBS script can be used to delete a folder and all of its contents including any subfolders on a local machine. The script can be distributed as is or can be used in a group policy.

 

VBS Script:

 

strFolderName = "C:\Test"

Set fso = CreateObject("Scripting.FileSystemObject")

If fso.FolderExists(strFolderName) Then

fso.DeleteFolder strFolderName

End If

MsgBox "Done"

 

 

 

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

VBS Script To Set A Local Machines Time With the Windows 2003 Server PDC Emulator

 

This VBS script will allow you to set the time on a local machine to the official Windows 2003 Server domain time by promoting you for the PDC Emulator name.

 

The script can also be used to run in a scheduled task for troublesome machines.

 

VBS Script:

 

strPdcEmulator = InputBox ("Enter Your PDC Emulator Name")

 

Set WshShell = WScript.CreateObject("WScript.Shell")

objcmnd = "Cmd /C Net Time \\" & strPdcEmulator & " /Set /y"

 

WshShell.Run(objcmnd)

MsgBox "Done"

 

 

 

Posted by dhite | with no comments
Filed under:

VBS Script To Send WQL Queries For Installed Collections To Excel

 

This VBS script will take a site server name and site code and will enumerate all of the installed Collections WQL queries to Excel.

 

VBS Script:

 

strServer = InputBox ("Enter Site Server Name")

strDatabase = InputBox ("Enter Three Letter Site Code")

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

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

objExcel.Cells(1, 2).Value = "WQL Query"

 

Const adOpenStatic = 3

Const adLockOptimistic = 3

 

Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _

"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase

 

Set objRecordSet = CreateObject("ADODB.Recordset")

objRecordSet.Open "Select CN.Name,CR.WQL" & _

" From Collection_Rules_SQL CR" & _

" Join v_Collection CN on CR.CollectionID = CN.CollID", objConnection, adOpenStatic, adLockOptimistic

 

objRecordSet.MoveFirst

Do Until objRecordSet.EOF

 

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

objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("WQL").Value

objRecordSet.MoveNext

intRow = intRow + 1

Loop

 

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

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("A1")

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

 

MsgBox "Done"

 

 

 

Posted by dhite | with no comments
Filed under:

VBS Script To Send SQL Queries For Installed Collections To Excel

 

This VBS script will take a site server name and site code and will enumerate all of the installed Collections SQL queries to Excel.

 

VBS Script:

 

strServer = InputBox ("Enter Site Server Name")

strDatabase = InputBox ("Enter Three Letter Site Code")

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

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

objExcel.Cells(1, 2).Value = "SQL Query"

 

Const adOpenStatic = 3

Const adLockOptimistic = 3

 

Set objConnection = CreateObject("ADODB.Connection")

objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _

"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase

 

Set objRecordSet = CreateObject("ADODB.Recordset")

objRecordSet.Open "Select CN.Name,CR.SQL" & _

" From Collection_Rules_SQL CR" & _

" Join v_Collection CN on CR.CollectionID = CN.CollID", objConnection, adOpenStatic, adLockOptimistic

 

objRecordSet.MoveFirst

Do Until objRecordSet.EOF

 

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

objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("SQL").Value

objRecordSet.MoveNext

intRow = intRow + 1

Loop

 

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

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

Set objSheet = objExcel.ActiveWorkbook.Worksheets(1)

Set objRange = objExcel.Range("A1")

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

 

MsgBox "Done"

 

 

 

Posted by dhite | with no comments
Filed under:

SQL Queries To Locate Client Resources For A Specified Subnet

 

Provided here are SQL queries that will allow you to locate client resources from a specified subnet. The first example specifies (=) a subnet, the second one uses a wildcard (Like) and finally the third allows you to specify multiple subnets.

 

Specific Search:

 

Select Distinct

SD.Name0,

IP.Ip_Subnets0

From v_Ra_System_IpSubnets IP

Join v_R_System SD on IP.ResourceID = SD.ResourceID

Where IP.Ip_Subnets0 = '192.168.1.0'

 

Wildcard Search:

 

Select Distinct

SD.Name0,

IP.Ip_Subnets0

From v_Ra_System_IpSubnets IP

Join v_R_System SD on IP.ResourceID = SD.ResourceID

Where IP.Ip_Subnets0 Like '192.168.1.%'

 

Multiple Searches:

 

Select Distinct

SD.Name0,

IP.Ip_Subnets0

From v_Ra_System_IpSubnets IP

Join v_R_System SD on IP.ResourceID = SD.ResourceID

Where IP.Ip_Subnets0 In

('192.168.1.0',

'192.168.2.0')

Order by IP.Ip_Subnets0,SD.Name0

 

 

 

Posted by dhite | with no comments
Filed under:

SQL Query To Count Microsoft Office Versions From Add And Remove Programs

 

This SQL Query will allow you to get a count of the Microsoft Office versions deployed.

 

SQL Query:

 

Select

Count(ResourceID) Counts,

DisplayName0,

Publisher0,

Version0

From v_Add_Remove_Programs

 

Where Publisher0 = 'Microsoft Corporation'

And DisplayName0 Like 'Microsoft Office%'

 

Group By DisplayName0, Publisher0, version0

Order By Counts Desc

 

 

 

Posted by dhite | with no comments
Filed under:

Dressed To A Tea

 

In the Victorian era “High Tea” was a formal occasion and required that you dress yourself fashionably as if you were going to a wedding or other such affair. When you were dressed for the occasion you were said to be Dressed to a Tea or Dressed to go to a Tea.

 

Today the term “Dressed To a T” is meant to imply that you are dressed up in your Sunday finest for no obvious reason.

 

 

Posted by dhite | with no comments
Filed under:

SQL Query To Retrieve OpsMgr 2007 Machine Information

 

This SQL Query will return the following machine information from the OperationsManager database: Machine Name, Machine Fully Qualified Domain Name (FQDN), IP Address, Active Directory (AD) site, Organizational Unit (OU) name and if the machine is a virtual machine or not.

 

SQL Query:

 

Select   

NetbiosComputerName 'Machine Name',

NetworkName FQDN,

IPAddress 'IP Address',

ActiveDirectorySite 'AD Site',

OrganizationalUnit 'OU Name',

 

'Virtual Machine' = Case

When IsVirtualMachine = 0 Then 'No'

Else 'Yes'

End

 

From Mt_Computer

 

 

 

Posted by dhite | with no comments
Filed under:

Free Microsoft Virtualization Pro Monthly Email Newsletter

 

The free Text or HTML Virtualization Pro e-Newsletter will address the latest headlines related to virtualization and highlight the benefits of this hot technology. Great newsletter features will include columns and blog entries by the Microsoft virtualization team experts, showcase of customer’s success stories, spotlight on virtualization solutions and scenarios and will provide readers with a wealth of virtualization resources.

 

Microsoft Virtualization Newsletter

http://go.microsoft.com/?linkid=7327681

 

 

 

Posted by dhite | with no comments
Filed under: ,

Opening The SQL Server Management Studio From The Command Line

 

Here you will find information on how to start the SQL Server Management Studio (SSMS) from a shortcut or from the command line.

 

The following will open the SSMS by using Windows Authentication and will bypass the splash screen. The query editor will be set to the SMS_XXX database:

 

SqlWb -E -S SQLServerName -d SMS_XXX –NoSplash

 

Note: Change SQLServerName as needed.

 

SqlWb Arguments:

 

SqlWb (Options)

 

Scriptfile Specifies one or more script files to open.

Projectfile Specifies a script project to open.

Solutionfile Specifies a solution to open.

 

-S Server Name

-d Database Name

-U Username

-P Password

-E Windows Authentication

-Nosplash Bypasses the splash screen

 -? Help

 

 

 

Posted by dhite | with no comments

HTA Script To Estimate Your Horses Weight

 

Here is another HTA script that I wrote just for fun for all of my horse owner readers and my myITforum equine friends out there to help with estimating their horse’s weight. If you are a horse owner it is important to know your horses approximate weight when giving shots, when you need to worm them each quarter or when you visit the Vet and they need to know the horse’s estimated weight before giving you their prescription.

 

Thanks to Dianne B. and Scott G. for testing the script against actual weights and for their suggestions.

 

HTA Script:

 

<Html>

<Head>

<Title>HTA Script</Title>

<Style>

Body {Background-Color: CornSilk}

</Style>

 

<HTA:Application

Caption = Yes

Border = Thick

ShowInTaskBar = No

MaximizeButton = Yes

MinimizeButton = Yes>

 

<script Language = VBScript>

Sub WindowsLoad

strHTML = strHTML & "<tr>"

strHTML = strHTML & "<td width='10%' bgcolor = 'SeaShell'><font color = 'Orange'><b></td>"

strHTML = strHTML & "</tr>"

A = xGirth.value

B = xlength.value

C = A * A * B \ 330

strHTML = strHTML & "<tr>"

Window.Document.Title = "Equine Weight Calculator"

strHTML = strHTML & "<td align='center'>" & "Your Horse Weights Approximately " & C & " (Lbs)" & "</td>"

strHTML = strHTML & "</tr>"

strHTML = strHTML & "</table>"

DataArea.InnerHTML = strHTML

End Sub

 

</script><Body>

<p><h3 align = center><font color='Orange'>Please Visit myITforum.Com</font></h3>

<div></div>

<div align="center">Girth (Inches): <Input Type = "Text" Name = "xGirth"></div><P>

<div align="center">Length (Inches): <Input Type = "Text" Name = "xLength"></div><P>

<div align="center"><Input Type = "Button" Value = "Run Script" Name = "Run_Button" onClick = "WindowsLoad"></div><P>

<Span Id = "DataArea"></Span></Body><Div Align = "Center">

<P><A Href="http://myitforum.com/cs2/blogs/dhite">Created For myITforum By Don Hite</A>

 

 

How to Measure The Girth And Length

http://www.gaitedhorses.net/Articles/HorseWeightMes.gif

 

 

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

Verifying Configuration Manager WMI Rights For The SMS Admins Group

 

If you are experiencing WMI connectivity issues accessing the SMS Provider and are seeing errors in the SmsAdminUi log file such as: Error(ConnectServer): Possible UI connection error you may have a misconfigured WMI rights. To check the WMI rights on the sever follow the steps here:

 

1. On the Site Server open the Windows Management Infrastructure (WMI) Console (wmimgmt.msc).

 

2. Right mouse click on WMI Control (Local) and select “Properties” from the context menu.

 

3. Select the “Security” leaf and expand the “Root” leaf and then select “SMS”

 

4. Select the “Security” button on the bottom left hand side.

 

5. Select “SMS Admins” from the “Group or user names” box and ensure that the group has the following rights:

 

Enable Account

Enable Remote

 

Note: If the SMS Admins group or a SMS group that you have created for accessing the console is not shown you can add the group at this point but make sure that the Enable Remote is checked as the Enable Account is applied by default.

 

 

Posted by dhite | with no comments
Filed under:

Henny Youngman One-Liners

 

Henry "Henny" Youngman (1906 – 1998) British-born American comedian and violinist.

 

  • 2 Guys in a health club, one is putting on pantyhose. "Since when do you wear pantyhose?" "Since my wife found it in the glove compartment!"
  • A man goes to a psychiatrist. The doctor says, "You're crazy" The man says, "I want a second opinion!" "Okay, you're ugly too!"
  • A Polish guy locked his keys in the car. It took an hour to get his wife out.
  • Can you really afford to give anybody a piece of your mind?
  • Doctor, my leg hurts. What can I do?" The doctor says, "Limp!
  • He's a real pain in the neck; of course, some people have a lower opinion of him.
  • Hollywood called me, asking me, "How much to do a movie with Farrah Fawcett?" "$50,000" They called back, "How about $20,000?" I said, "I'll pay it!"
  • I don't know what makes you so stupid, but it really works.
  • I had a nightmare last night. I dreamed Dolly Parton was my mother and I was a bottle baby.
  • I haven't talked to my wife in three weeks. I didn't want to interrupt her.
  • I just got back from a pleasure trip. I took my mother-in-law to the airport.
  • I miss my wife's cooking -- as often as I can.
  • I played a great horse yesterday! It took seven horses to beat him
  • I take my wife everywhere, but she keeps finding her way back.
  • I took my wife to a wife-swapping party. I had to throw in some cash.
  • I've been married for 49 years. Where have I failed?
  • My doctor grabbed me by the wallet and said, "Cough!"
  • My horse was so late getting home, he tiptoed into the stable
  • My horse's jockey was hitting the horse. The horse turns around and says "Why are you hitting me, there is nobody behind us!"
  • My room is so small, the mice are hunchbacked.
  • My wife and I have the secret to making a marriage last. Two times a week, we go to a nice restaurant, a little wine, good food. She goes Tuesdays, I go Fridays.
  • My wife will buy anything marked down. Last year she bought an escalator.
  • My wife will buy anything marked down. She brought home two dresses and an escalator.
  • She must have Egyptian blood. Every time I try to kiss her she says, "Tut, Tut!"
  • Someone stole all my credit cards, but I won't be reporting it. The thief spends less than my wife did.
  • Take my wife, please!
  • That was the first time I saw a horse start from a kneeling position!
  • That's a nice suit you're wearing. When did the clown die?
  • The horse I bet on was so slow, the jockey kept a diary of the trip.

 

 

Posted by dhite | with no comments
Filed under:

Can Anyone Tell Me Part Two…

 

  • How did they get Teflon on pans when nothing is supposed to stick to Teflon?
  • How do "Keep off the grass" signs get out there in the grass?
  • Who is General failure? And why is he reading my hard drive?
  • Why does sour cream have an expiration date?
  • Why doesn't glue stick to the bottle?
  • Why doesn't Tarzan have a full beard?
  • Why don’t we call babies new people since we call the elderly old people?
  • Why don't sheep shrink when it rains?
  • Why is a carrot more orange than an orange?
  • Why is an open door called ajar when it is adoor?
  • Why is it called a Television set when you only have one?
  • Why is it called the Department of Interior when they manage everything outside?
  • Why is pizza delivered in a square box?
  • Why is the man who invests money called a Broker?
  • Why is the third hand on the watch called the second hand?
  • Why is the time of day with the slowest traffic called rush hour?
  • Why isn't the number 11 pronounced onety one?
  • Why isn't there butt flavored dog food?
  • Why isn't there mouse flavored cat food?
  • Why do we call it a near miss when it is in fact a near hit?

 

 

Posted by dhite | with no comments
Filed under:

VBS Script Example For Calling An SMS Or ConfigMgr View And Sending Specific Fields To Excel

 

This VBS script will provide you with and example of how you can call an SMS 2003 or ConfigMgr 2007 SQL database view and retrieve selected columns or fields and write them to an Excel spreadsheet.

 

VBS Script:

 

strServer = InputBox ("Enter SQL Server Name")

strDatabase = InputBox ("Enter Three Letter Site Code")

 

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 = "Client Version"

objExcel.Cells(1, 3).Value = "User Name"

objExcel.Cells(1, 4).Value = "User Domain"

 

Set objConnection = CreateObject("ADODB.Connection")

Set objCommand = CreateObject("ADODB.Command")

Set objRecordset = createobject("ADODB.RecordSet")

 

objConnection.Open "Provider=SQLOLEDB;Data Source =" & strServer & ";" & _

"Trusted_Connection=Yes;Initial Catalog =SMS_" & strDatabase

objCommand.activeconnection = objConnection

 

objCommand.CommandText = "Select * From V_R_System"

Set objRecordset = objCommand.Execute

 

Do Until objRecordSet.EOF

objExcel.Cells(intRow, 1).Value = objRecordset("Name0")

objExcel.Cells(intRow, 2).Value = objRecordset("Client_Version0")

objExcel.Cells(intRow, 3).Value = objRecordset("User_Name0")

objExcel.Cells(intRow, 4).Value = objRecordset("User_Domain0")

objRecordSet.MoveNext

intRow = intRow + 1

Loop

 

objExcel.Range("A1:D1").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("A1")

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

objConnection.close

 

MsgBox "Done"

 

 

 

Posted by dhite | 1 comment(s)
Filed under:
More Posts Next page »