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"
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.
strPdcEmulator = InputBox ("Enter Your PDC Emulator Name")
Set WshShell = WScript.CreateObject("WScript.Shell")
objcmnd = "Cmd /C Net Time \\" & strPdcEmulator & " /Set /y"
WshShell.Run(objcmnd)
This VBS script will take a site server name and site code and will enumerate all of the installed Collections WQL queries to Excel.
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
This VBS script will take a site server name and site code and will enumerate all of the installed Collections SQL queries to Excel.
objExcel.Cells(1, 2).Value = "SQL Query"
objRecordSet.Open "Select CN.Name,CR.SQL" & _
objExcel.Cells(intRow, 2).Value = objRecordSet.Fields("SQL").Value
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:
Where IP.Ip_Subnets0 Like '192.168.1.%'
Multiple Searches:
Where IP.Ip_Subnets0 In
('192.168.1.0',
'192.168.2.0')
Order by IP.Ip_Subnets0,SD.Name0
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
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.
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.
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
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
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
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
Window.Document.Title = "Equine Weight Calculator"
strHTML = strHTML & "<td align='center'>" & "Your Horse Weights Approximately " & C & " (Lbs)" & "</td>"
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
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.
Henry "Henny" Youngman (1906 – 1998) British-born American comedian and violinist.
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.
strServer = InputBox ("Enter SQL Server Name")
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 objCommand = CreateObject("ADODB.Command")
Set objRecordset = createobject("ADODB.RecordSet")
objCommand.activeconnection = objConnection
objCommand.CommandText = "Select * From V_R_System"
Set objRecordset = objCommand.Execute
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")
objExcel.Range("A1:D1").Select
objExcel.Selection.Interior.ColorIndex = 19
objConnection.close