Saturday, September 8, 2012

How to Move databases for SCCM 2012


How to Move databases for SCCM 2012

1.       On SCCM Site Server
a.       Stop site server using  (Configuration Manager site installation folder)\bin\X64\00000409\preinst.exe /STOPSITE
2.       On Reporting Server
a.       Backup the encryption key using Reporting Services Config tool
b.      Stop the Report Server service using the Reporting Services Config tool
3.       On Wsus server
a.       Stop IIS Admin Service
b.      Stop Update Services Service
4.       On SQL Server for WSUS DB
a.       Detach SUSDB – single user rollback immediate
b.      Move both files (mdf and ldf)
c.       Attach SUSDB to new SQL server
d.      Verify Wsus server machine account  has login permissions and is member of webService Role
5.       On SQL Server for Reporting Services DB
a.       Detach SCCM_ReportServer
b.      Detach SCCM_ReportServerTempDB
c.       Move all 4 files (2 mdf and 2 ldf)
d.      Attach both databases
e.      Verify that RSExecRole is a database role on both SCCM_ReportServer and SCCM_ReportServerTempDB.
                                                               i.      If not, create role per http://msdn.microsoft.com/en-us/library/cc281308.aspx
6.       On SQL Server for SCCM DB
a.       Detach CM_(Site Code)
b.      Move both files (mdf and ldf)
c.       Attach CM_(Site Code) to new SQL Server run the following stored procedure as a query: sp_configure ‘clr enabled’,1; reconfigure.
d.      Enable common language runtime (CLR) integration
e.      Verify SCCM Site servers are Local Administrators on the SQL server
f.        Add the site server system account as login account with admin rights to SQL
7.       On Wsus server
a.       Edit Backend Database registry key to point to new name/instance
                                                               i.      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\UpdateServices\Server\Setup\SqlServerName. In the Value text box, type [BEName]\[InstanceName], and then click OK. If the instance name is the default instance, type [BEName].
                                                             ii.      HKEY_LOCAL_MACHINE\Software\Microsoft\Update Services\Server\Setup\wYukonInstalled. In the Value text box, type 0, and then click OK. This indicates that Windows Internal Database is not used.
                                                            iii.      Locate the following key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\UpdateServices\Server\Setup\SqlInstanceIsRemote. In the Value text box, change the value to 1, and then click OK.
b.      Start IIS Admin Service
c.       Start Update Services Service
8.       On Report Server
a.       Open Reporting Services Config tool
b.      On Database page, select the new SQL server instance and click connect.
c.       Select the report server database and click apply
d.      On encryption key page click restore
e.      Setup the execution account
f.        Restart Report Server
9.       On SCCM Server
a.       Run Configuration Manager Setup Wizard using Setup.exe from  (Configuration Manager site installation folder)\BIN\X64\setup.exe.  Not from install media- you won't have the same options.
b.      Choose site maintenance or reset site
c.       Select Modify SQL Server configuration
d.      After wizard finishes restart SCCM site server
e.      In SCCM console update the properties of the Reporting Services Point role to use the SCCM Databse on the new server.  Administration>Servers and Site System Roles>Pick the server with the Reporting Services  Point Role>Pick Reporting services point>Right click and choose properties>Change Site Database Server name.

Saturday, April 21, 2012

Sccm 2012 install error

Following the windows-noob setup guide at:  http://www.windows-noob.com/forums/index.php?/topic/4422-using-sccm-2012-rc-in-a-lab-part-1-installation/


And came across this unusual error during setup:

Fail to create SQL Server Certificate, ConfigMGR installation cannot be completed.

Looking at the setup logs I see this only slightly more descriptive error:

Failed to get SID for user (NT Service\MSSQLSERVER)
ERROR: Failed to get the buffer size for LookupAccountName. Error = 1722

After much googling found this link from Yuri that suggests temporarily changing SQL to run under local system instead of the NT Service\MSSQLSERVER account. Worked great!

http://itbl0b.blogspot.com/2011/11/strange-error-while-installing.html

Friday, May 1, 2009

windows 7 bootable USB

Don't forget, you can extract the Windows 7 iso onto a bootable USB.  Makes the install much quicker:

   1. diskpart

   2. select disk 1 (if disk 1 is your USB stick)

   3. clean

   4. create partition primary

   5. select partition 1

   6. active

   7. format fs=fat32   (ntfs also works).

   8. assign

   9. exit

10. Extract the ISO

11. xcopy d:\*.* /s/e/f e:\ (Copy Windows 7 iso content to the Flash Drive E:)

Thursday, April 30, 2009

Windows 7 RC is on MSDN now

If you have access to MSDN, go grab it!  Remember that your February Beta keys will still work.  If you need to regenerate them then these instructions will help:

http://www.neowin.net/news/main/09/01/10/psstheres-how-to-get-your-windows-7-beta-key

Wednesday, April 29, 2009

ConfigMgr.next revealed at MMS09

The MMS09 State of the Union session revealed what the next version of SCCM will look like.  The MMC is gone in favor of the Outlook-esqe toolbar (wonder-bar) as seen in SCOM 2007.  It also requires Server 2008 64-bit as well as SQL 2008 64-bit.  The other big piece of news is the elimination of ASP web reports in favor of SQL Server reporting services only.  See all the screen shots and read more about it on Kenneth van Surksum's blog:

http://www.techlog.org/archive/2009/04/29/mms_2009_information_about_mic

Vista SP2 and Server 08 SP2 RTM'd

SP2 for vista and server 08 have gone RTM.  Additionally the block offering SP1 is being removed (your GPO to block SP1 will no longer work). 

http://windowsteamblog.com/blogs/windowsvista/archive/2009/04/28/windows-vista-sp2-rtm-windows-vista-sp1-blocker-tool-removed.aspx

All the SP2 goodness can be found here:

http://technet.microsoft.com/en-us/windows/dd767387.aspx

Office 2007 SP2 is out

Just released:

http://www.microsoft.com/downloads/details.aspx?FamilyID=b444bf18-79ea-46c6-8a81-9db49b4ab6e5&displaylang=en

time to download, test and deploy!

Saturday, April 25, 2009

windows 7 will have near complete xp compatibility

A new feature being announced is XP mode for Windows 7.  XP mode is essentially an application running in a Virtual PC virtual environment.  Installing the application in the virtual pc environment will result in it being published to windows 7 as an application.  The requirements for this technology includes processor virtualization support (Intel VT or AMD-V).  It will be a separate out of band update released in final form to coincide with the release of windows 7 (so it's not actually built in).  Paul Thurrott has a nice set of screen shots on the whole thing here: http://www.winsupersite.com/win7/xp_mode_pre_shots.asp

Monday, January 19, 2009

Unable to import AI license file

So our software licensing team asked about using SCCM's Asset Intelligence to track software license usage at our company. After going through all of our normal internal testing we were ready to import our xml formated license file into our site. However when we tried to import it on our production server we received a single message:

error

Unable to connect to the site database

Not very useful since my console and site server were obviously talking to the site database just fine. I spent many hours troubleshooting this one myself before calling Premier support. At which time I spent many more hours troubleshooting on the phone with them and fearing that the issue would be unresolved. We went through all kinds of troubleshooting of both my SQL server setup and my site server setup.

The only error message with any meaning behind it was when we tried to run the import manually:

D:\SMSPROV\bin\i386>mvlsimport.exe /file //server/share/MSLtest.xml

Failed to get Site Database configuration information.Failed to get Site Database connection.Failed to intialize.

Yes, those are forward slashes, per explicit instructions by Microsoft Support.

My gut told me it was a bug in SCCM, but how my site differed eluded both me and Microsoft support. Ultimately, by sheer luck a stumbled across the steps that would enable me to reproduce the bug on my own. My site had an unrelated hardware failure and I had to rebuild and recover it. As I rebuilt it I tried the import several times along the way, until it finally failed. Once I was able to reproduce the bug I let Microsoft know how my site differed from a working site. Turns out there is a bug importing the license file if the smsprovider is installed on another computer other than the site server. Support was then finally able to confirm that this was a bug that they could reproduce and would notify the development team. In the absence of an actual fix, they provided me with a workaround. The workaround is to export the sql node of the sms registry key from the site server and import it onto the smsprovider computer. If you are switching architecture you will have to update the key to compensate for wow6432node as well.

Export this key from your 32-bit site server: [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\SMS\SQL Server]

Import this key into your 32-bit smsprovider computer.

Or, if your provider is 64-bit, find and replace \software\Microsoft\ with \software\wow6432node\Microsoft

Key will now be in this format:

[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\SMS\SQL Server]

Now import the new key onto your 64-bit smsprovider computer.

Thursday, January 15, 2009

wsutil to change your wsus server's ports

Following up on my recovery of a sccm site.  My original recovery doc did not specify that during the wsus install, wsus needs to be setup to use its own custom website on ports 8530 (for http) and 8531 (for https).  I later found that if you miss this step  (When you notice your site fails to sync with its wsus database) then there is a simple utility installed with wsus that will allow you to change it.  From the command line:

wsusutil.exe usecustomwebsite true

Also, if your site just isn't syncing for no apparent reason, I've found that a wsus reset may help:

wsusutil.exe reset

You can find wsutil on the wsus server in the program files\Update Services\Tools folder.

Monday, January 12, 2009

Chrome on Windows 7 64-Bit Beta (7000)

This weekend I installed the current windows 7 64-bit beta (build 7000).  All my favorite apps installed just fine including the SCCM console.  I even managed to find a beta build of the rsat tools: http://www.microsoft.com/downloads/details.aspx?FamilyID=82516c35-c7dc-4652-b2ea-2df99ea83dbb&displaylang=en  The only thing that I spent a significant amount of work getting to run was google chrome.  I'm still in love with it, and just started using the 2.0 dev beta.  So of course I want to run it on top of my windows 7 beta.  Well now you can.  In the target part of your shortcut to chrome.exe add -in-process-plugins.  It runs just fine now.  Credit to: BlogsDNA

Oh by the way, windows 7 boots faster on the same machine I was previously running vista 64!

Friday, January 9, 2009

Recovery of SCCM Site Failure

Despite the fact that Microsoft has recovery information posted in their online support docs ( http://technet.microsoft.com/en-us/library/bb680474.aspx), site recovery is still a confusing task.  I've gone through several site recoveries and here are the notes from my last one, where the central site happened to fail.  An important note that I don't think is explained very well is that you have to have a functioning site setup the same way as the old site before you can recover the old site.

So before starting the site recovery review the original site setup procedure.  If you don't have one documented, then see the excellent write up by Ying Li: http://myitforum.com/cs2/blogs/yli628/archive/2008/06/25/setup-configmgr-2007-sp1-from-start-to-finish.aspx

Notes from recovery of Central site on 12/17/08.

1. OS, Server name, Site Code, and Drive layout (OS on C: and program files on drive d: ) should match original hardware.  (Do not move from 64-bit to 32-bit OS).

2. Install the OS and configure as normal

3. Give the machine account admin rights on the SQL server

4. Install WSUS 3.0 with SP1.  Do not use the default website.  Use custom website.  During install point it to the remote SQL server (if you use a remote sql server to host wsus metadata).  Do not overwrite the contents of the database.  Do not use the configuration wizard to setup wsus.  Simply exit when the configuration wizard starts.

5. Start copying the backup files to the local machine since it can take 1/2 hour.

6. Install the correct version of SCCM

a. Make sure to reuse the same program path (d:\sms for our Primary sites since they were upgrades from sms.  d:\sccm for our Secondary sites, since they were fresh installs when we set them up).  This part is critical.  When you do the recovery step, your site will to use the original setup paths that were in use prior to the site failure.  Changing the paths will cause a significant headache!

b. On a new fully patched system you will not pass the prereq check.  Double click on each item to see how to resolve the issue.  You should be able to resolve every error.

c. After resolving the MMC sp3 issue, it will still show up as an warning in prereq check, that is fine if you are sure you have applied sp3 for MMC.  The setup routine does not correctly query the registry to see that lastest version of the hotfix that Microsoft issued.

d. You can ignore the warning about SQL server authentication mode if you typically run SQL under the system account (without hardening SQL).

e. If you are attempting to restore a site that has a remote provider and point it back to the correct remote provider machine, the installer will complain that machine already has a provider.

1. On the provider machine, the registry key is blocking the install of the new remote provider, so remove the HKLM\SOFTWARE\Microsoft\SMS\Providers key.

2. On the provider machine, connect to root\sms with WBEMTEST and press the 'Enum Classes button'. No input is necessary, just press 'OK' to do an 'Immediate only' search. In the Query Results dialog window, click on the 'SMS_ProviderLocation' and press the 'Delete' key. Close out of all of these dialogs.

3. Delete the SMSPROV folder on the root.

4. Add the new site server machine as a local administrator and remove the old site server (if applicable).

Note: Provider fix, pasted from http://social.technet.microsoft.com/forums/en-US/configmgrsetup/thread/bb307748-7638-404d-a6a4-982827a051c8/

f. All other site servers will install the provider on themselves.

g. On the SQL DB server detach the old DB.  Create a new DB with the same name and file locations.  Give the smssite server db_owner on the db.

7. After the install has completed successfully run the site recovery wizard.

a. Close the console if open

b. Start>all programs>Microsoft System Center>Config Mgr 2007>Config Mgr Site Repair Wizard

c. Redsite and ROSsite do not have local DP's installed.  Choose the option to skip package verification.

8. Reset permissions for site in AD.

a. Open AD users and Computers> System> System Management

b. Open properties and give site server full control on Systems Management container.

c. Open advance properties and change permissions so that they apply to "This object and all descendant objects"  (this is not the default so be sure to do it).

9. Restore the site control file

a. Copy  site_control_files sitectrl_<SiteCode>.ct0 to D:\sms\inboxes\sitectrl.box

b. Rename file from sitectrl_<SiteCode>.ct0 to sitectrl.ct0

10. After recovery perform a site reset

a. Rerun setup from Start>all programs>Microsoft System Center>Config Mgr 2007>

b. Choose site reset

11. Set user group permissions for recovered site and related site servers

a. Computer mgmt>local users and groups>Groups

b. Sms_sitetositeconnection_<sitecode>  should contain the parent server and any child servers that need to connect to the site.

c. Sms_siteSystemtoSiteServer_<sitecode> should contain any parent or child site that needs to write to the site's DB.

d. Sms Reporting Users should contain any domain accounts that have reporting rights.

e. Sms admins should contain your sms administrators domain accounts.

12. If this was the central site with the wsus updates, then the wsus updates folders need to be reshared with the same share names.  Check the software updates deployment packages nodes.  On each package open the package properties.  The general tab will show the share name that the packages is expected to be found on.  The central site's machine account will need full control of this share.

13. Reset the wsus db:

a. From the cmd prompt:  c:\program files\Update Services\tools\wsusutil.exe reset

b. Wait 1 hour

c. Force a Synchronization on the Update Repository

d. Verify wsus is syncing properly: wsyncmgr.log for errors.

14. Verify backup share permissions for newly restored site.  Our backups are set for a share on another server, which is then backed up to tape.  This can be verified in the site maintenance node and by reviewing the smsbkup.log located in the backup share.

15. If this was the central site, recreate the backup schedule for the site control file.  A scheduled task that runs every 15 mins to dump the site control file and copy them to another machine:

a. site_control_file_backup.bat

D:\sms\bin\i386\00000409\preinst.exe /Dump

xcopy d:\*.ct0 backup_location\site_control_files /C /Y

16. Check and review system logs for errors for the next several days.

17. Monitor Site Status for errors.  The only errors should be on the central site and be related to unapproved clients trying to get policy.  Recheck in 24 hours.

18. Verify successful backups by reviewing the smsbkup.log located in the backup share.

Wednesday, December 10, 2008

Config Manager Usability Study

Microsoft is conducting a usability study for the next version of SCCM.  If your in the Redmond area and available Jan 12-23rd you can participate.  To join send an email to itusable@microsoft.com.  Put ConfigMgr in the subject line: Source

Monday, December 1, 2008

Client Health Check Script- Take 2

In final testing of the Client Health Check Script, I found that ccmsetup doesn't finish running the install during machine startup on any XP machine that I tested.  I spent over 16 hours trying to figure out why before going with an alternative solution.  Instead of running ccmsetup during machine startup, I now create a system scheduled task to run ccmsetup 5 minutes in the future.  Since it's a one time task it cleans itself up.  Here is the modified script:

Attached: Download

'==========================================================================
' 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
' Run sccm_client_health_check.vbs /smsserver:smsserver /email:1stemail@company.com /email1:2ndemail@company.com
'==========================================================================
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 "####################################"

'********************************************************HARD CODED COMMAND LINE

OVERRIDES********************************************************
'***********************************************************UNCOMMENT ONLY IF

NECESSARY***********************************************************
'smsserver = "smsserver" 'Should reflect the PMP/PDP for each office
'platform = "" 'No need to modify
'Email = "wphillips@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()
checkEmail1CMD()
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()
On Error Resume Next
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()
On Error Resume Next
logfile.writeline "CheckingPlatformCMD"
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()
On Error Resume Next
logfile.WriteLine "Inside checkEmailCMD"
If email = "" Then
If WScript.Arguments.Named.Exists("email") Then
email = True
logfile.WriteLine ("Email command line argument specified as = " & WScript.Arguments.Named("email"))
End If
Else
logfile.WriteLine ("Email hardcoded command line override specified as = " & email)
email = True
End If
End Function
Function checkEmail1CMD()
On Error Resume Next
logfile.WriteLine "Inside checkEmail1CMD"
If email1 = "" Then
If WScript.Arguments.Named.Exists("email1") Then
email1 = True
logfile.WriteLine ("Email1 command line argument specified as = " & WScript.Arguments.Named("email1"))
End If
Else
logfile.WriteLine ("Additional email hardcoded command line override specified as = " & email)
email1 = True
End If
End Function


Function checkAdminShare()
On Error Resume Next
logfile.WriteLine "Inside 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()
On Error Resume Next
logfile.writeline "Inside 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 checkBITSrunning()
On Error Resume Next
logfile.writeline "Inside checkBITSRunning"
'Start BITS running
Results = ServiceState("BITS")
If LCase(Results) = LCase("Running")Then
logfile.writeline "BITS is running"

Else
logfile.WriteLine "BITS service is in a stopped state, attempting to start"
KickService("BITS")
End If
End Function

Function checkClient()
On Error Resume Next
logfile.writeline "Inside 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 1000
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 1000
Call Cleanup
WScript.Quit
End Select
End If
End Function

Function checkLogsUpdate()
On Error Resume Next
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("Log files are 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()
On Error Resume Next
'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()
On Error Resume Next
' 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()
On Error Resume Next
'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 already 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
' =====================================================
Function AdvCliInst(ComSpec)
On Error Resume Next
logfile.writeline "Inside AdvCliInst"
logfile.WriteLine "Calling Bits Check"
objCurTime = Time()
objCurHour = Hour(objCurTime)
objCurMin = Minute(objCurTime)+5
objInstallTime = objCurHour & ":" & objCurMin
Call checkBITSrunning()
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
If Exist (Wscript.Arguments.Named("smsserver") & "\SMSClient\ccmsetup.exe") Then
'smsinstall = ComSpec & " /c \\" & Wscript.Arguments.Named("smsserver") & "\SMSClient\ccmsetup.exe" & InstallArgs
smsinstall = "at " & objInstallTime & " \\" & Wscript.Arguments.Named("smsserver") & "\SMSClient\ccmsetup.exe" & InstallArgs
logfile.writeline "Calling SCCM Client installation with below command line:"
logfile.writeline "smsinstall = " & smsinstall
' Run SMS Client Installation
Call EmailMessage("SMS Install", Compname & " -Installing SCCM Client as " & smsinstall)
WshShell.Run smsinstall,0,False
Else
logfile.WriteLine "Cannot Find SCCM client installer"
Call EmailMessage("SMS Installer Missing", Compname & " -" & Wscript.Arguments.Named("smsserver") & "\SMSClient\ccmsetup.exe")
End If

End If
End Function
' =====================================================
' 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.CC = WScript.Arguments.Named("email1")
' objEmail.To = "smsadmins@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
' =====================================================

Friday, November 7, 2008

Interactive Services Detection Service

Yesterday another admin notified me that his Vista machine prompted him before showing a message from a program I had distributed via SCCM.  The name of the prompt was "Interactive Services Dialog Detection", and it was requesting to show him a message.

image001

Selecting "Show me the message" hides the desktop and allows the user to see the message.  After viewing the message, the user had to click on "Return Now" to get back to the desktop.

This event was a surprise to me.  I've been running Vista since it came out and the program we advertised has been advertised for the last 3 years, and we run it every month.  After researching this service, I discovered that it is a new security feature in Vista.  Designed to protect users by intercepting messages run under another security context.  In this case, the program is advertised to run whether or not a user is logged on, but allow users to interact with the program.  When these options are chosen in SCCM, the program runs under the machine account as a service.  Since this program pops up a message, we chose the option to allow users to interact so they can see the message and click okay on it.  Vista may see this as a security risk if the Interactive Services Detection service is running.  We checked 4 different Vista machines, and it appears the default behavior is the service is Stopped and set to Manual.   UAC did not appear to have any affect on this service.  Apparently this admin had done something else to set this service to Running.  There are several available ways to resolve this issue:

  • Choose the option to run the program only when a user is logged on, and run it as the user.
  • Don't make the program interactive (user will not see the program).
  • Stop the Interactive Services Detection service.

Ignore it.  Vista is doing it's job of being safer.  Users may have to click an extra prompt.

I don't really recommend stopping or disabling the service since that is a built in security feature of Vista.  But it will prevent the prompt from appearing if desired.

Wednesday, November 5, 2008

Organize Collections with Drag and Drop

One of the plans we've had since I took over the administration of Configuration Manager is to organize the objects in the admin console.  SCCM makes it easier than SMS since it supports drag and drop.  The catch is that it only supports it with certain types of objects.  Collections is one of the object types that doesn't support drag and drop.  The only way I found to reorganize collection objects was to make a link of a collection to a second collection.  Making this link actually makes a 2nd instance of the collection appear in the hierarchy.  Then you can go back and safely delete the original collection.  The other option is to use a Microsoft provided SMS tool called CollTree.  Yes, the program does work with SCCM.  After downloading the SMS 2003 SDK you can compile the executable from \Program Files\Microsoft Systems Management Server 2003 SDK V3\Samples\VB\CollTree\CollTree.vbp  It's not as great as if Microsoft had built this functionality into the Admin Console, but at least it works!  Download a compiled version of CollTree here: http://myitforum.com/cs2/blogs/bleary/attachment/68439.ashx

Credits to Brian Leary for pointing out this useful tool: http://myitforum.com/cs2/blogs/bleary/archive/2006/12/01/colltree-drag-and-drop-collections-for-sms-2003.aspx

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