Thursday, October 23, 2008

Upgrade BITS

As companies move from SMS 2003 to SCCM one of the items frequently mentioned is the desire to predeploy the latest version of BITS (Background Intelligent Transfer Service).  This makes it possible to deploy the client without requiring a reboot.  However, Microsoft didn't really provide a method for doing the BITS deployment.  So I wrote my own.  Download the latest versions of BITS from: 2000, XP, 2003, x64- XP and 2003

They will need to be in a subdirectory named bin of this script.  The script will require a drive letter to run, so when you create the program be sure to specify that option.  The nice thing about this script is that you can deploy to everybody, and it will only upgrade those that need it.

'==========================================================================
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
'
' NAME: Install_Bits.vbs
' AUTHOR: Bill Phillips , ESRI
' DATE : 10/22/2008
'
' COMMENT:
'==========================================================================
On Error Resume Next
Dim strOSName, strSPName, strComputerType, systemroot, detectfile
Dim objFile, strFileVersion, strInstallFile


Set objShell = CreateObject ("Wscript.Shell")
set objEnv = objShell.Environment("Process")
systemroot = objEnv("SYSTEMROOT")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objExp = new regexp 'Create the RegExp object


detectOS()
detectFileversion(systemroot & "\system32\QMgr.dll")
compareBITSVersion(strFileVersion)
installBITS()

' ********************************************************************************
'Detect OS Function
'********************************************************************************
Function detectOS()
For Each objOS In GetObject("winmgmts:").InstancesOf ("Win32_OperatingSystem")
strOSName = objOS.Caption
strSPName = "SP" & objOS.ServicePackMajorVersion
Next

For Each objComputer In GetObject("winmgmts:").InstancesOf ("Win32_ComputerSystem")
strComputerType = objComputer.systemtype
Next

'need to normalize data (too many different versions of windows)
objExp.Pattern = "2000"
If objEXP.Test (strOSName) Then
strOSName = "win2k"
End If

objExp.Pattern = "XP"
If objEXP.Test (strOSName) Then
strOSName = "winXP"
End If

objExp.Pattern = "2003"
If objEXP.Test (strOSName) Then
strOSName = "w2k3"
End If

objExp.Pattern = "Vista"
If objEXP.Test (strOSName) Then
strOSName = "Vista"
End If

objExp.Pattern = "2008"
If objEXP.Test (strOSName) Then
strOSName = "w2k8"
End If
End Function

Function detectFileversion(detectfile)
If objFSO.FileExists(detectfile) Then
Set objFile = objFSO.GetFile(detectfile)
strFileVersion = objFSO.GetFileVersion(detectfile)
End If

End Function

Function compareBITSVersion(strFileVersion)
Select Case strFileVersion
' Case for Windows 2000 Server and Pro
Case "6.6.2600.1596"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Windows XP SP2
'Case "6.7.2600.3143"
Case "Fake"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Windows XP SP3
Case "6.7.2600.5512"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Server 2003 SP1
Case "6.6.3790.1830"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Server 2003 SP2
Case "6.6.3790.3959"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Vista RTM
Case "7.0.6000.16386"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1

' Case for Vista and Server 2008 SP1 x32 & x64
'Case "7.0.6001.18000"
Case "fake"
'wscript.echo "BitsVersion Passed"
WScript.quit
WScript.Sleep 1
' Case for failure
Case Else
'WScript.Echo "Bits Failed"
selectBITSinstall()
End Select
End Function

Function selectBITSinstall()
Select Case strComputerType
Case "x64-based PC"
Select Case strOSName
Case "w2k3"
strInstallFile = "WindowsServer2003.WindowsXP-KB923845-x64-ENU.exe"
Case "winXP"
strInstallFile = "WindowsServer2003.WindowsXP-KB923845-x64-ENU.exe"
End Select
Case "X86-based PC"
Select Case strOSName
Case "win2k"
strInstallFile = "Windows2000-KB842773-x86-ENU.exe"
Case "winXP"
strInstallFile = "WindowsXP-KB923845-x86-ENU.exe"
Case "w2k3"
strInstallFile = "WindowsServer2003-KB923845-x86-ENU.exe"
End Select
End Select

' no match found so quitting
If strInstallFile = "" Then
WScript.Quit
End If

End Function

Function installBITS()
'Turn off prompt for unknown locations
objEnv("SEE_MASK_NOZONECHECKS") = 1


objShell.Run ("bin\" & strInstallFile & " /passive /norestart /overwriteoem")', 1, True

'Turn prompt back On
objEnv.Remove("SEE_MASK_NOZONECHECKS")
End Function

Wednesday, October 22, 2008

Client Health Check Script

See updated post: http://smsimpossible.blogspot.com/2008/12/client-health-check-script-take-2.html

1e used to have a client health check script for sms 2003. The script would reinstall the client or force a repair depending on what part of the check it failed. Since the release of SCCM they have not updated the script. I believe the old script will probably still work just by changing the install directory, but I have a rewritten version of the script that we use so I'm providing it below. I don't think there is anything wrong with posting this, but I will remove it if 1e asks me to do so. To use the script you must specify the siteserver. Also the sccm/client directory must be shared out and the script will need to be modified to reflect the share directory. After meeting these 2 requirements the script is usable. You may also specify an smtp email server in the email section and who the email should be sent to. The siteserver and email recipient may be passed as arguments or hard coded into the script.

'==========================================================================
' VBScript Source File -- Created with SAPIEN Technologies PrimalScript 4.0
' NAME: SCCM_Client_Health_Check.vbs
' AUTHOR: Bill Phillips , ESRI
' DATE : 10/20/2008
'
' COMMENT: Code rewrite for SCCM client taken from 1E ClientHealth Script for SMS client
'==========================================================================
On Error Resume Next

Dim smsserver, platform, email
Dim domainrole, ComSpec, diffdate, enddate, fso, filedate, SmsClient, returncode, Results
Dim ISmsClient, DiscoveredSite, AssignedSite
Dim servicename, startdate, strMessage, strSMSPolEval, windir, wmi, colItems, wShShell, Compname, present, objShare
Dim BitsVersion, tempdir, logfile, logsize

Set WshShell = WScript.CreateObject("WScript.Shell")
WinDir = WshShell.ExpandEnvironmentStrings("%windir%")
Compname = WshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
ComSpec = WshShell.ExpandEnvironmentStrings("%COMSPEC%")
tempdir = WshShell.ExpandEnvironmentStrings("%temp%")

'Set up the loggong
Set fso = CreateObject("Scripting.FileSystemObject")
Set logfile = fso.OpenTextFile(tempdir & "\SCCM_Client_Health_Check.Log",2,True)


logfile.writeline "####################################"
logfile.writeline "Begining SCCM Client Health Check Script"
logfile.writeline "####################################"

'Either uncomment variables below or pass arguments to script:
'sccm_client_health_check.vbs /smsserver:smststserver /email:recepient@company.com
'********************************************************HARD CODED COMMAND LINE OVERRIDES********************************************************
'***********************************************************UNCOMMENT ONLY IF NECESSARY***********************************************************
'smsserver = "smststserver" 'Should reflect the PMP/PDP for each office
'platform = "" 'No need to modify
'Email = "recepient@company.com" 'Should be set to go to an alias that includes the needed peoeple.
'********************************************************HARD CODED COMMAND LINE OVERRIDES********************************************************
'***********************************************************UNCOMMENT ONLY IF NECESSARY***********************************************************
checkSCCMserverCMD()
checkPlatformCMD()
checkEmailCMD()
checkAdminShare()
checkCCMSetupRunning()
checkClient()
checkLogsUpdate()
checkBITSversion()
checkServices()
checkAssignment()
logfile.writeline "Cleaning Up"
Call Cleanup
logfile.writeline "Ending Processing"
WScript.Quit


'Check to see if SCCM server is specifed as an argument or hardcoded into script
Function checkSCCMserverCMD()
If smsserver = "" Then
If Wscript.Arguments.Named.Exists("smsserver") Then
If Wscript.Arguments.Named("smsserver") <> "" Then
logfile.writeline "smsserver specified in command line is " & WScript.Arguments.Named("smsserver")
Else
logfile.writeline "/smsserver parameter is the incorrect format. Please see documentation"
WScript.Quit
End If
Else
logfile.writeline "Missing /smsserver: in command line"
WScript.Quit
End If
Else
logfile.WriteLine "The SCCMserver hardcoded command line override specified as = " & smsserver
End If
End Function

Function checkPlatformCMD()
If platform = "" Then
domainrole = GetDomainRole()
If Wscript.Arguments.Named.Exists("platform") Then
If Wscript.Arguments.Named("platform") <> "" Then
platform = Wscript.Arguments.Named("platform")
logfile.WriteLine "platform = " & platform
If Not CInt(platform) = CInt(domainrole) Then
logfile.WriteLine "System running is not the correct platform as specified"
WScript.Quit
End If
End If
End If
Else
logfile.WriteLine "platform hardcoded command line override specified as = " & platform
domainrole = GetDomainRole()
If Not CInt(Platform) = CInt(domainrole) Then
logfile.WriteLine "System running is not the correct platform as specified"
WScript.Quit
End If
End If
End Function

Function checkEmailCMD()
If email = "" Then
If WScript.Arguments.Named.Exists("email") Then
email = True
End If
Else
logfile.WriteLine ("Email hardcoded command line override specified as = " & email)
'email = True 'uncomment if you use hardcoded email in script
End If
End Function

Function checkAdminShare()
'Check for Admin$ - If not present then log
Set wmi = getobject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colItems = wmi.ExecQuery("Select * From Win32_Share",,48)
present = "FALSE"
For Each objShare In colItems
If LCASE(objShare.Name) = "admin$" Then
present = "TRUE"
End If
Next
If present <> "TRUE" Then
If Email = True Then
logfile.writeline "Sending email that Admin$ is missing"
Call EmailMessage("Admin$ Missing", Compname & " does not have an Admin$.")
Else
logfile.writeline "Admin$ is missing."
End If
End If
End Function

Function checkCCMSetupRunning()
'Abort if ccmsetup running
Results = ServiceState("ccmsetup")
If LCase(Results) = LCase("Running")Then
logfile.writeline "Sending email that ccmsetup service is running and script is aborting"
Call EmailMessage("Aborting Client Installation", "ccmsetup is running on " & CompName)
WScript.Quit

logfile.writeline "Exiting script processing because ccmsetup service is running"
WScript.Quit

Elseif LCase(Results) = LCase("Stopped")Then
logfile.WriteLine "ccmsetup service is in a stopped state, attempting to start"
KickService("ccmsetup")
End If
End Function

Function checkClient()
' SMS Client COM object available, Version Installed, & WMI Namespace available
Set SmsClient = GetObject("winmgmts:ROOT/CCM:SMS_Client=@")
If Err Then
'Advanced client not installed
logfile.writeline "Advanced Client not installed, calling AdvCliInst to install the client"
Call AdvCliInst(ComSpec)
WScript.Sleep 10000
Call Cleanup
WScript.Quit
Else
logfile.writeline SmsClient.ClientVersion
Select Case SmsClient.ClientVersion
'IMPORTANT! >>>>>>>>> Adjust CASE as necessary, but do *not* remove it! <<<<<<<<IMPORTANT!
'Alter this by adding an additional CASE statement followed by the version in quotes for each SMS client
'version which is allowed in the hierarchy. This can also be used as an additional cleanup method after
'upgrading clients for those that might have missed this via software distribution
'Case "2.50.3174.1018"
'Case "2.50.4160.2000" 'SP2 Version
Case "4.00.6221.1000" 'configMGR sp1 client
logfile.writeline "SMS Client Version Passed"
WScript.Sleep 1
Case Else
logfile.writeline "Calling AdvCliInst routine to install SMS Advanced client"
Call AdvCliInst(ComSpec)
WScript.Sleep 10000
Call Cleanup
WScript.Quit
End Select
End If
End Function

Function checkLogsUpdate()
Set SmsClient = GetObject("winmgmts://./root/ccm:SMS_Client")
' SMS Logs recently updated
logfile.writeline "Begining to evaluate " & windir & "\system32\CCM\Logs\PolicyEvaluator.log"
strSMSPolEval = windir & "\system32\CCM\Logs\PolicyEvaluator.log"
startdate = ShowFileAccessInfo(strSMSPolEval, Compname)
logfile.writeline "startdate = " & startdate
enddate = date()
logfile.writeline "enddate = " & enddate

If isDate(startdate) Then
diffdate = DateDiff("d", startdate, enddate)
logfile.writeline "diffdate = " & diffdate
End If

If diffdate > 21 Then
If Email = True Then
logfile.writeline "diffdate is greater than 21 days, sending email"
Call EmailMessage(CompName & " is out of date", Compname & " has not updated is logs in 21 days or more - attempting client repair")
End If
logfile.writeline "diffdate is greater than 21 days, attempting to repair SMS Client"
smsClient.RepairClient
wscript.quit
End If
End Function

Function checkBITSversion()

'Check BITS version, email if out of date
logfile.writeline "Checking BITS version by looking at " & windir & "\system32\QMgr.dll"
If fso.FileExists(windir & "\system32\QMgr.dll") Then
BitsVersion = fso.GetFileVersion(windir & "\system32\QMgr.dll")
logfile.writeline "BitsVersion is " & BitsVersion
Select Case BitsVersion

' Case for Windows 2000 Server and Pro
Case "6.6.2600.1596"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Windows XP SP2
Case "6.7.2600.3143"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Windows XP SP3
Case "6.7.2600.5512"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Server 2003 SP1
Case "6.6.3790.1830"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Server 2003 SP2
Case "6.6.3790.3959"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Vista
Case "7.0.6000.16386"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1

' Case for Server 2008 SP1
Case "7.0.6001.18000"
logfile.writeline "BitsVersion Passed"
WScript.Sleep 1


' Case for failure
Case Else
If Email = True Then
logfile.writeline "BITS is out of date, sending email"
Call EmailMessage("BITS out of date", Compname & " - BITS version is at " & BitsVersion)
Else
logfile.writeline "BITS is out of date, exiting script processing"
WScript.Quit
End If
End Select
Else
If Email = True Then
logfile.writeline "Unable to process BITS version because " & windir & "\system32\QMgr.dll is missing. Sending email."
Call EmailMessage("File Missing", "%system32%\QMgr.dll" & " is missing on " & Compname)
Else
logfile.writeline "Unable to process BITS version because " & windir & "\system32\QMgr.dll is missing. Exiting Script processing."
WScript.Quit
End If
End If
End Function

Function checkServices()

' SMS Agent Host Service started
logfile.writeline "Calling KickService"
Call KickService("CcmExec")

' Remote Registry Service started
logfile.writeline "Calling RemoteRegistry"
Call KickService("RemoteRegistry")
End Function

Function checkAssignment()
'Ensure that the client is assigned to a site if its not assigned to any
logfile.writeline "Checking to make sure SMS Client has site assignment"
Set ISmsClient = CreateObject ("Microsoft.SMS.Client")
AssignedSite = ISmsClient.GetAssignedSite
If NOT Len(AssignedSite & "")>0 Then
logfile.writeline "Client is not assigned, attempting to AutoDiscover and set"
ISmsClient.EnableAutoAssignment 1
DiscoveredSite = ISmsClient.AutoDiscoverSite
ISmsClient.SetAssignedSite DiscoveredSite,0
logfile.writeline "Client is now assigned to " & ISmsClient.GetAssignedSite
End If
logfile.writeline "Client is now assigned to " & ISmsClient.GetAssignedSite
End Function




' =====================================================
' KickService function
' =====================================================
Function KickService(servicename)
On Error Resume Next
logfile.writeline "Inside KickService"
Dim Results, wmi, Service, returncode, Service2, Started
Results = ServiceState(servicename)
logfile.writeline "servicename = " & servicename
logfile.writeline "Results = " & Results
set wmi = getobject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

If NOT LCase(Results) = LCase("Running")Then
set Results = wmi.execquery("select state from win32_service where name='" & servicename & "'")
For Each Service In Results
' Start service
returncode = Service.StartService
logfile.writeline "returncode = " & returncode
if returncode <> 0 Then
If Email = True Then
logfile.writeline "SMS Client Service Failure " & servicename & " failed to start on " & CompName
Call EmailMessage("Start Service Error", "SMS Client Service Failure " & servicename & " failed to start on " & CompName)
Call Cleanup
logfile.writeline "Quiting Script"
WScript.Quit
Else
logfile.writeline "Displaying message to user - Error starting service your Windows Management Service (" & servicename & ") - Call The Help Desk immediately"
msgbox "Error starting service your Windows Management Service (" & servicename & ") - Call The Help Desk immediately"
Call Cleanup
logfile.writeline "Quiting Script"
WScript.Quit
End If
end If
Do Until Started = True
'IMPORTANT! >>>>>>>>> Adjust sleep as necessary, but do *not* remove it! <<<<<<<<IMPORTANT!
logfile.writeline "Sleeping for 2 seconds..."
logfile.writeline "Use the below text to see how many times the script looped to start the Service"
WScript.Sleep 2000 'Sleep for 2 Seconds
set Results = wmi.execquery("select state from win32_service where name='" & servicename & "'")
for each Service2 In Results
if lcase(Service2.State) = lcase("Running") Then
logfile.writeline "Started = " & Started
Started = True
end If
Next
Loop
Next
End If
End Function
' =====================================================
' ServiceState subprocedure
' =====================================================
Function ServiceState(servicename)
On Error Resume Next
logfile.writeline "Inside ServiceState"
logfile.WriteLine "Checking " & servicename & " service"
Dim wmi, Results, Service, StateResults, StartMode
set wmi = getobject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
set Results = wmi.execquery("select state from win32_service where name='" & servicename & "'")
For Each Service In Results
StateResults = Service.State
logfile.writeline "StateResults = " & StateResults
Next
ServiceState = StateResults
End Function
' =====================================================
' AdvCliInst subprocedure
' =====================================================
Sub AdvCliInst(ComSpec)
On Error Resume Next
logfile.writeline "Inside AdvCliInst"
Dim smsinstall, WshShell, InstallArgs

Set WshShell = WScript.CreateObject("WScript.Shell")
ComSpec = WshShell.ExpandEnvironmentStrings("%COMSPEC%")
If ComSpec = "" Then
If Email = True Then
logfile.writeline "SMS Client Installation Failure", "The SMS Client failed to Install On " & CompName
Call EmailMessage("SMS Client Installation Failure", "The SMS Client failed to Install On " & CompName)
Call Cleanup
logfile.writeline "Exiting Script Processing"
WScript.Quit
Else
logfile.writeline "Displaying Message to user - Windows Management Service Installation Failed. Please contact The Help Desk"
MsgBox "Windows Management Service Installation Failed. Please contact The Help Desk"
Call Cleanup
logfile.writeline "Exiting Script Processing"
WScript.Quit
End If
Else
InstallArgs = ""
If Wscript.Arguments.Named.Exists("params") Then
If Wscript.Arguments.Named("params") <> "" Then
InstallArgs = Wscript.Arguments.Named("params")
logfile.writeline = "InstallArgs = " & InstallArgs
End If
End If
smsinstall = ComSpec & " /c \\" & Wscript.Arguments.Named("smsserver") & "\SMSClient\ccmsetup.exe SMSSLP=smststserver Disablesiteopt=true FSP=smststserver SMSSITECODE=tst" & InstallArgs
logfile.writeline "Calling SCCM Client installation with below command line:"
logfile.writeline "smsinstall = " & smsinstall
' Run SMS Client Installation
WshShell.Run smsinstall,0,False
End If
End Sub
' =====================================================
' GetDomainRole function
' =====================================================
Function GetDomainRole
On Error Resume Next
logfile.writeline "Inside GetDomainRole"
Dim domainroles, wmi, domainrole
Set wmi = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set domainroles = wmi.ExecQuery("SELECT DomainRole FROM Win32_ComputerSystem")
For Each domainrole in domainroles
GetDomainRole = domainrole.DomainRole
logfile.writeline "GetDomainRole = " & GetDomainRole
Next
Set domainroles = Nothing
Set wmi = Nothing
End Function
' =====================================================
' EmailMessage subprocedure
' =====================================================
Function EmailMessage(Subject, Body)
On Error Resume Next
logfile.writeline "Inside EmailMessage"
logfile.writeline "Email Subject: " & Subject
logfile.writeline "Email Body: " & Body
Dim objEmail, objemailfrom
' email using a generic user account as system is being booted up and user may not have logged on yet
Set objEmail = CreateObject("CDO.Message")
objemailfrom = WScript.Arguments.Named("smsserver") & "@company.com"
objEmail.From = objemailfrom
objEmail.To = WScript.Arguments.Named("email")
' objEmail.To = "receipants@company.com"
objEmail.Subject = Subject
objEmail.Textbody = Body
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = _
"smtp.company.com"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
logfile.writeline "Sending Email"
objEmail.Send
Set objEmail = Nothing
End Function
' =====================================================
' ShowFileAccessInfo function
' =====================================================
Function ShowFileAccessInfo(filespec, Compname)
On Error Resume Next
logfile.writeline "Inside ShowFileAccessInfo"
Dim fso, f, filespec_date, FSpace
Set fso = CreateObject("Scripting.FileSystemObject")
If fso.FileExists(filespec) Then
Set f = fso.GetFile(filespec)
logfile.writeline "f = " & f
filespec_date = f.DateLastModified
logfile.writeline "filespec_date = " & filespec_date
FSpace = Instr(filespec_date," ") - 1
logfile.writeline "FSpace = " & FSpace
ShowFileAccessInfo = Left(filespec_date,FSpace)
logfile.writeline "ShowFileAccessInfo = " & ShowFileAccessInfo
Else
If Email = True Then
logfile.writeline "File Missing - " & filespec & " is missing On " & Compname
Call EmailMessage("File Missing", filespec & " is missing On " & Compname)
logfile.writeline "Exiting Script Processing"
WScript.Quit
End If
End If
End Function
' =====================================================
' Destroy any objects
' =====================================================
Sub Cleanup
On Error Resume Next
logfile.writeline "Inside Cleanup"
Set WshShell = Nothing
Set ComSpec = Nothing
Set windir = Nothing
Set strCompName = Nothing
Set SmsClient = Nothing
End Sub
' =====================================================

Thursday, October 16, 2008

open file - security warning

In our SCCM environment we frequently use the option to run from server instead of download and run.  One of the issues we've seen from time to time is if our script calls another program that was downloaded from the internet it may have had the untrusted source bit set during the download.  In our scripts we get around the Open File - Security warning dialog box by temporarily turning off zone checking.  At the end of the script we turn zone checking back on.  No need to add servers to trusted sites via group policy!  More info on this problem here:

set objShell = CreateObject("Wscript.shell")
Set objEnv = objShell.Environment("PROCESS")

' ********************************************************************************
'Main Routine
'*********************************************************************************
objEnv("SEE_MASK_NOZONECHECKS") = 1
objShell.Run("taskkill.exe /F /IM foo.exe"),,False
Install_Application()
objEnv.Remove("SEE_MASK_NOZONECHECKS")
WSCRIPT.QUIT

' ********************************************************************************
'Install Application
'*********************************************************************************
Function Install_Application()
'setup program
objShell.run("fooInstall.exe /silent"),1,true
Wscript.Sleep(5000)
End Function

Thursday, October 9, 2008

configmgr right click tools

If your familiar with the sms 2003 right click tools, then your probably already know that there are new console extenstions available for SCCM. My favorite is Rick Houchin's SCCM Right Click tools: http://myitforum.com/cs2/blogs/rhouchins/archive/2008/04/09/sccm-right-click-tools.aspx Download version 1.7 directly from: http://myitforum.com/cs2/blogs/rhouchins/0613ConfigMgrTools.zip For those of you who haven't tried them, I highly recommend that you do since they make life so much easier.

Wednesday, October 8, 2008

Update Package versus Refresh Package

You may have noticed that if you right click on the distribution point node of a Package you will get an option to Update Distribution points. If you open the node and right click on an individual DP you will get an option to refresh the package on that distribution point. There is no option to refresh a package on all DP's and there is no option to Update a package on just one DP. What's going on here? Well, each function is slightly different. When you create a package and assign a source location to it, that package is actually stored on the site server in the SMSPKG folder as a compressed file in the form of PackageID.pck extension. This folder is shared out from the site server as \\server\SMS_CPSx$, where x represents the drive letter it is located on. When choosing the option to Update a package a delta file of the changes is created from the specified source location and the version number is incremented for both the source and client policy. The delta file is what gets sent out to the DP's. Choosing the option to refresh a package will actually repair a package at a DP by recopying the entire compressed package from the local site server to the DP. There is no update of any changes that may have occured at the package source.

More info: http://technet.microsoft.com/en-us/library/bb892806.aspx
and here: http://www.serverwatch.com/tutorials/article.php/1474011

Monday, October 6, 2008

Script to Force Client Inventory on 64-Bit OS

In my previous post I posted the script to force HW and SW inventory on a client. However if you run the script on 64-bit vista or '08, you will get a 800a01ad error code (I'm guessing this will also happen of 64-bit XP, but didnt' test it). The specific error is: ActiveX component can't create object: 'CPAPPLET.CPAppletMgr' . The issue is that configmgr's applet's are 32-bit only. On a 64-bit system, Open control panel and you will not see the configmgr cpl, unless you open the "View 32-bit Control Panel" applet. By default, 64-bit versions of windows call the 64-bit version of the scripting host (wscript or cscript), which will only talk to the 64-bit part of the control panel. So the solution is to call the 32-bit scripting host that will talk to the 32-bit control panel items. A simple batch file to run from either verison of the OS to launch your vbs using the correct scripting host will do the trick:

if exist %systemroot%\SysWOW64\cscript.exe goto run64
\\server\share\swinventory.vbs
exit
:run64
%systemroot%\SysWOW64\cscript.exe \\server\share\swinventory.vbs
exit

Friday, October 3, 2008

Script to Force Hardware or Software Inventory

In my previous post I stated that we were allowing users to opt in to a collection on their own by putting a dummy exe on their computers.  The collection is setup to update its membership nightly.  However, clients need to run software inventory to report the new exe back to the Management Point.  Here's a VB script that clients can run to kick this process off.  Credit to Chris Stauffer at myitforum for the original code ( http://myitforum.com/cs2/blogs/cstauffer/archive/2007/04/04/script-to-perform-a-full-sms-inventory.aspx).  Also, I added in the Hardware Inventory version in case your adding registry keys, wmi classes, other HWinv type items.  If you want to verify that it's running check the inventoryagent.log file on the client.

On Error Resume Next

ForceSoftwareInventory()
ForceHardwareInventory()

'*********************************************************************************************************
'Force Software Inventory on the Client
'*********************************************************************************************************

Function ForceSoftwareInventory()
Set sho = CreateObject("WScript.Shell")
strSystemRoot = sho.expandenvironmentstrings("%SystemRoot%")
strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1))
'Run a SMS Software Inventory

Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
    If Instr(action.Name,"Software Inventory Collection Cycle") > 0 Then
        action.PerformAction  
'        WScript.Echo action.name
End If
Next
End Function

'*********************************************************************************************************
'Force Hardware Inventory on the Client
'*********************************************************************************************************

Function ForceHardwareInventory()
Set sho = CreateObject("WScript.Shell")
strSystemRoot = sho.expandenvironmentstrings("%SystemRoot%")
strCurrentDir = Left(Wscript.ScriptFullName, (InstrRev(Wscript.ScriptFullName, "\") -1))
'Run a SMS Hardware Inventory

Set cpApplet = CreateObject("CPAPPLET.CPAppletMgr")
Set actions = cpApplet.GetClientActions
For Each action In actions
    If Instr(action.Name,"Hardware Inventory Collection Cycle") > 0 Then
        action.PerformAction  
'        WScript.Echo action.name
End If
Next
End Function