Wednesday, April 18, 2007

Collection Based on File needed (outlook.hol)

Sometimes you need to send a file to the computer multiple times. This is true with the Outlook.hol file. For those that are new to it, this file contains calendar entries for custom and standard information. Use this to file to say give the dates of company vacations or events. Of course users still need to import the functions in to Outlook. At the end of this I will show you how to add it in. To push this file you will need 1 collection with 2 queries.

Query 1: Old HOL file
---------------------
select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = "OUTLOOK.HOL" and SMS_G_System_SoftwareFile.FileModifiedDate < "20070206 23:00:00.000" ------------------------- Query 2: No HOL file ------------------ select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Name not in (select distinct SMS_G_System_COMPUTER_SYSTEM.Name from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_SoftwareFile on SMS_G_System_SoftwareFile.ResourceID = SMS_R_System.ResourceId where SMS_G_System_SoftwareFile.FileName = "OUTLOOK.HOL") -------------------- As you update the new HOL change the date on the OLD hold query so it will pull in computers that need the new file. As they inventory they will be removed from the query. In your package you will need to create a batch file that copies over the old one. -----copyHOL.bat----- copy /y Outlook.hol "C:\Program Files\Microsoft Office\OFFICE11\1033" -------------------- This will copy over the old file. Then simply send out a message to let people know it is up to date. Or if you update monthly or weekly let the users know. Use the popup I have listed earlier for a notice after it installs. Please note that if Outlook it open then it won't update. It is better to install when no user is logged in. To add to your outlook access the Tools Options >Calendar Options> Add Holidays

Select the new categories or click ok to update the ones you have. Please note that you need to turn on File Inventory and search for the outlook.hol file.

Tuesday, April 17, 2007

Remote Activation of SMS Agent on Client

In an SMS enviroment you must have the SMS Agent running on the client or you can't do anything. In a strickly user enviroment this doesn't matter since the user can't turn it off, but if you have a user that has admin rights to his/her machine then they have the power to turn you off. Finding them is simple enough, look at the computers that haven't sent in an inventory in quite a while, heart beat or other options. The problem is getting that service restarted.

Here is a vbscript that will turn the service back on for a number of computers.
-------------------------
Const SW_NORMAL = 1
'change comps to match the number of computers in your array
Dim Comps(1)
Comps(0)="computer1"
Comps(1)="Computer2"
for each strComputer in Comps
strCommand = "net start ccmexec"
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\cimv2")
Set objStartup = objWMIService.Get("Win32_ProcessStartup")
Set objConfig = objStartup.SpawnInstance_
objConfig.ShowWindow = SW_NORMAL
Set objProcess = objWMIService.Get("Win32_Process")
intReturn = objProcess.Create (strCommand, Null, objConfig, intProcessID)
'remark lines if you don't want to see the success or failure of the program
If intReturn <> 0 Then
Wscript.Echo "Process could not be created." & _
vbNewLine & "Command line: " & strCommand & _
vbNewLine & "Return value: " & intReturn
Else
Wscript.Echo "Process created." & _
vbNewLine & "Command line: " & strCommand & _
vbNewLine & "Process ID: " & intProcessID End If
Next
----------------------------

This is simple but effective. You can run it manually or set it as a Scheduled Task on the server.
Remember you must have admin rights on the computer to run this, so we are talking about an local admin account or domain admin.

Thursday, April 12, 2007

DateAdd in Query/Collection

Many of you have already discovered some of the nice features and added benifits of upgrading to Sp 2 for SMS 2003. What you might not be aware of is that you can now use the DateAdd function in your query. The only down side is that you can only add it while editing the query manually. There is no WYSISYG method of adding or editing it. So once you add it you no longer have the editor.

Below is an example of how to use it to keep a computer in a collection for 2 days based on the MCNSDATA.ImageDate. I will describe this more later. Basically we are using a custom MIF file to add a computer to a new computer collection where it will stay until the end of the second day. It will then automatically remove itself. Expect to see more of the "New Computer" subject. I will have more about what we are doing with new computer provisioning.
------------------------------
select SMS_R_System.ResourceID,SMS_R_System.ResourceType,SMS_R_System.Name,SMS_R_System.SMSUniqueIdentifier,SMS_R_System.ResourceDomainORWorkgroup,SMS_R_System.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId inner join SMS_G_System_MCNSDATA on SMS_G_System_MCNSDATA.ResourceID = SMS_R_System.ResourceId where SMS_G_System_MCNSDATA.ImageDate >= DateAdd(dd,-2,GetDate())
---------------------------------