· 9 years ago · Jan 27, 2017, 01:41 AM
1<job id="ZTIGather">
2 <script language="VBScript" src="ZTIUtility.vbs"/>
3 <script language="VBScript" src="ZTIDataAccess.vbs"/>
4 <script language="VBScript">
5
6' // ***************************************************************************
7' //
8' // Copyright (c) Microsoft Corporation. All rights reserved.
9' //
10' // Microsoft Deployment Toolkit Solution Accelerator
11' //
12' // File: ZTIGather.wsf
13' //
14' // Version: 6.2.5019.0
15' //
16' // Purpose: Gather information and process rules controlling deployment
17' // process.
18' //
19' // Usage: cscript.exe [//nologo] ZTIGather.wsf [/debug:true] [/localonly]
20' //
21' // ***************************************************************************
22
23Option Explicit
24RunNewInstance
25
26
27'//----------------------------------------------------------------------------
28'// Global Constants
29'//----------------------------------------------------------------------------
30
31Public Const iDRVariant = 200
32Public Const iDRMaxChar = 255
33
34Public Const sSectionSettings = "Settings"
35Public Const sSectionDefaultGateway = "DefaultGateway"
36
37
38'//----------------------------------------------------------------------------
39'// Main Class
40'//----------------------------------------------------------------------------
41
42Class ZTIGather
43
44 Dim iRetVal
45 Dim bSkip
46 Dim sIniFile
47 Dim dicProperties, dicLists, dicOverwrite
48 Dim bLocalOnly
49
50
51 '//----------------------------------------------------------------------------
52 '// Constructor to initialize needed objects
53 '//----------------------------------------------------------------------------
54
55 Private Sub Class_Initialize
56
57
58 '//----------------------------------------------------------------------------
59 '// Create dictionary objects
60 '//----------------------------------------------------------------------------
61
62 oLogging.CreateEntry "------------------------- Object Initialization -------------------------", LogTypeInfo
63
64 Set dicProperties = CreateObject("Scripting.Dictionary")
65 dicProperties.CompareMode = TextCompare
66
67 Set dicLists = CreateObject("Scripting.Dictionary")
68 dicLists.CompareMode = TextCompare
69
70 Set dicOverwrite = CreateObject("Scripting.Dictionary")
71 dicOverwrite.CompareMode = TextCompare
72
73 End Sub
74
75
76 '//----------------------------------------------------------------------------
77 '// Main routine
78 '//----------------------------------------------------------------------------
79
80 Function Main
81
82 oLogging.CreateEntry "------------------------- Initialization -------------------------", LogTypeInfo
83
84 oLogging.ReportProgress "Initializing.", 1
85
86 '//----------------------------------------------------------------------------
87 '// Make sure the environment is in sync
88 '//----------------------------------------------------------------------------
89
90 SyncEnvironment
91
92
93 '//----------------------------------------------------------------------------
94 '// Get information about the machine and OS (unless skipped)
95 '//----------------------------------------------------------------------------
96
97 If not oUtility.Arguments.Exists("nolocalonly") then
98
99 oLogging.ReportProgress "Getting local computer information: Operating system", 10
100 iRetVal = GetOSVersion
101 TestAndLog iRetVal, "GetOSVersion for Gather process"
102
103 oLogging.ReportProgress "Getting local computer information: HAL", 15
104 iRetVal = GetHAL
105 TestAndLog iRetVal , "GetHAL for Gather process"
106
107 oLogging.ReportProgress "Getting local computer information: Networking", 20
108 iRetVal = GetNetworkInfo
109 TestAndLog iRetVal , "GetNetworkInfo for Gather process"
110
111 oLogging.ReportProgress "Getting local computer information: Distribution point", 25
112 iRetVal = GetDP
113 TestAndLog iRetVal , "GetDP for Gather process"
114
115 oLogging.ReportProgress "Getting local computer information: Windows Deployment Services", 30
116 iRetVal = GetWDS
117 TestAndLog iRetVal ,"GetWDS for Gather process"
118
119 oLogging.ReportProgress "Getting local computer information: Host name", 30
120 iRetVal = GetHostName
121 TestAndLog iRetVal , "GetHostName for Gather process"
122
123 oLogging.ReportProgress "Getting local computer information: Asset information", 30
124 iRetVal = GetAssetInfo
125 TestAndLog iRetVal ,"GetAssetInfo for Gather process"
126
127 oLogging.ReportProgress "Getting local computer information: Operating system", 35
128 iRetVal = GetOSSKU
129 TestAndLog iRetVal ,"GetOSSKU for Gather process"
130
131 oLogging.ReportProgress "Getting local computer information: Operating system", 40
132 iRetVal = GetCurrentOSInfo
133 TestAndLog iRetVal ,"GetCurrentOSInfo for Gather process"
134
135 oLogging.ReportProgress "Getting local computer information: Virtualization", 45
136 On Error Resume Next
137 iRetVal = GetVirtualizationInfo
138 TestAndLog iRetVal ,"GetVirtualizationInfo for Gather process"
139 On Error Goto 0
140
141 oLogging.ReportProgress "Getting local computer information: BitLocker", 48
142 On Error Resume Next
143 iRetVal = GetBitLockerInfo
144 TestAndLog iRetVal ,"GetBitLockerInfo for Gather process"
145 On Error Goto 0
146
147 Else
148 oLogging.CreateEntry "Skipping local settings gathering because it has already been done.", LogTypeInfo
149 End if
150
151
152 '//----------------------------------------------------------------------------
153 '// Send a discovery event
154 '//----------------------------------------------------------------------------
155
156 oLogging.CreateEvent 41000, LogTypeInfo, "Processing the " & oEnvironment.Item("Phase") & " phase.", oLogging.GetDiscoveryArray
157
158
159 '//----------------------------------------------------------------------------
160 '// Check if localonly was specified
161 '//----------------------------------------------------------------------------
162
163 If oUtility.Arguments.Exists("localonly") or UCase(oEnvironment.Item("GatherLocalOnly")) = "TRUE" then
164
165 oLogging.CreateEntry "Only gathering local settings (no rules processing).", LogTypeInfo
166 bLocalOnly = true
167
168 Else
169 bLocalOnly = false
170 End if
171
172
173 '//----------------------------------------------------------------------------
174 '// Determine what INI file to use
175 '//----------------------------------------------------------------------------
176
177 sIniFile = LocateIni
178 If sIniFile = "" and (not bLocalOnly) then
179 oLogging.ReportProgress "Gathering complete, but no INI file found.", 100
180 If oUtility.Arguments.Exists("optional") then
181 oLogging.CreateEntry "Unable to find optional rules INI file, rc = " & iRetVal & ", exiting", LogTypeInfo
182 Main = 0
183 Else
184 oLogging.CreateEntry "Unable to find rules INI file, rc = " & iRetVal, LogTypeError
185 Main = 8000
186 End if
187 EXIT FUNCTION
188 End if
189
190
191 '//----------------------------------------------------------------------------
192 '// Process rules and save results
193 '//----------------------------------------------------------------------------
194
195
196 If not bLocalOnly then
197
198 oLogging.ReportProgress "Processing rules.", 50
199
200
201 ' Gather properties
202
203 iRetVal = GetProperties(sIniFile, sSectionSettings)
204
205
206 ' Process rules
207
208 iRetVal = ProcessRules(sIniFile, sSectionSettings)
209 If iRetVal <> Success then
210 oLogging.CreateEntry "ERROR processing Ini settings. No further processing.", LogTypeError
211 Main = iRetVal
212 EXIT FUNCTION
213 End if
214
215
216 ' If an event service was specified ask for settings
217
218 If oEnvironment.Item("EventService") <> "" then
219 If oEnvironment.Item("LTIGUID") = "" then
220 oLogging.CreateEvent 41000, LogTypeInfo, "Identifying the client.", oLogging.GetDiscoveryArray
221 End if
222 QueryWebService ""
223 End if
224
225 Else
226
227 oLogging.CreateEntry "Skipping rules processing.", LogTypeInfo
228 iRetVal = Success
229
230 End if
231
232
233 '//----------------------------------------------------------------------------
234 '// Verify OSDComputerName is set for ConfigMgr deployments
235 '//----------------------------------------------------------------------------
236
237 If oEnvironment.Item("DeploymentMethod") = "SCCM" and oEnvironment.Item("OSDComputerName") = "" Then
238 oEnvironment.Item("OSDComputerName") = oEnvironment.Item("_SMSTSMACHINENAME")
239 End If
240
241
242 '//----------------------------------------------------------------------------
243 '// Remap variables
244 '//----------------------------------------------------------------------------
245
246 RemapVariables
247
248
249 ' All done
250
251 oLogging.ReportProgress "Gathering complete.", 100
252
253 Main = Success
254
255
256 End Function
257
258
259 '//----------------------------------------------------------------------------
260 '// Routines for getting information about the local machine
261 '//----------------------------------------------------------------------------
262
263
264 '//---------------------------------------------------------------------------
265 '// Function: GetOSVersion()
266 '// Purpose: Determine what OS is being used
267 '//---------------------------------------------------------------------------
268 Function GetOSVersion
269
270 Dim iRetVal, sOSCurrentVersion, sOSCurrentBuild, sCurrentBuildNumber, sProductType, sOSVersion
271 Dim bIsServerOS, bIsServerCoreOS, oInstances, oInstance
272
273
274 oLogging.CreateEntry "Getting OS info", LogTypeInfo
275
276
277 ' Initialization
278
279 iRetVal = Success
280 bIsServerOS = False
281 bIsServerCoreOS = False
282
283
284 ' Make sure WMI is available
285
286 If objWMI is Nothing then
287 oLogging.CreateEntry "Unable to obtain OS details since WMI is unavailable.", LogTypeError
288 GetOSVersion = 8001
289 Exit Function
290 End if
291
292
293 ' Get the current OS version and build from WMI
294
295 Set oInstances = objWMI.ExecQuery("select * from Win32_OperatingSystem")
296 For Each oInstance In oInstances
297 sOSCurrentVersion = oInstance.Version
298 sOSCurrentBuild = oInstance.BuildNumber
299 Next
300 oEnvironment.Item("OSCurrentVersion") = sOSCurrentVersion
301 oEnvironment.Item("OSCurrentBuild") = sOSCurrentBuild
302
303
304 ' For WinPE (which reports itself as "XP"), look for a registry key
305
306 If KeyExists("HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\MiniNT\") then
307 sOSVersion = "WinPE"
308 End if
309
310
311 ' Check the version we are running
312
313 If sOSVersion = "WinPE" then
314 bIsServerOS = False
315 bIsServerCoreOS = False
316 Else
317
318 ' Check for server core by seeing if Explorer.exe is missing
319
320 If not oFSO.FileExists(oEnv("WINDIR") & "\Explorer.exe") and sOSVersion <> "WinPE" then
321 bIsServerCoreOS = true
322 End if
323
324
325 ' Get the current build number from the registry
326
327 sCurrentBuildNumber = oShell.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\CurrentBuildNumber")
328
329
330 ' Check the product type
331
332 sProductType = oShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductType")
333 If Err then
334 oLogging.CreateEntry "WARNING - Unexpected error checking ProductType registry key: " & Err.Description & " (" & Err.Number & ")", LogTypeWarning
335 ElseIf sProductType = "ServerNT" or sProductType = "LanmanNT" then
336 bIsServerOS = True
337 End if
338 Err.Clear
339
340
341 Select Case sCurrentBuildNumber
342 Case "1381"
343 sOSVersion = "NT"
344 Case "2195"
345 sOSVersion = "2000"
346 Case "2600"
347 sOSVersion = "XP"
348 Case "3790"
349 sOSVersion = "2003"
350 Case Else
351
352 If Left(sOSCurrentVersion, 3) = "6.1" Then
353 If bIsServerOS then
354 sOSVersion = "2008R2"
355 Else
356 sOSVersion = "Win7Client"
357 End if
358 ElseIf Left(sOSCurrentVersion, 3) = "6.0" Then
359 If bIsServerOS then
360 sOSVersion = "2008"
361 Else
362 sOSVersion = "Vista"
363 End if
364 Else
365 oLogging.CreateEntry "Unknown operating system build number " & sCurrentBuildNumber & " found, setting OSVersion to 'Other'.", LogTypeInfo
366 sOSVersion = "Other"
367 End if
368 End Select
369
370 End if
371
372 oEnvironment.Item("OSVersion") = sOSVersion
373 oEnvironment.Item("IsServerOS") = oUtility.ConvertBooleanToString(bIsServerOS)
374 oEnvironment.Item("IsServerCoreOS") = oUtility.ConvertBooleanToString(bIsServerCoreOS)
375
376 oLogging.CreateEntry "Finished getting OS info", LogTypeInfo
377
378 GetOSVersion = iRetVal
379
380 End function
381
382
383 '//---------------------------------------------------------------------------
384 '// Function: GetAssetInfo()
385 '// Purpose: Get asset information using WMI
386 '//---------------------------------------------------------------------------
387 Function GetAssetInfo
388
389 Dim bIsLaptop, bIsDesktop, bIsServer, bOnBattery, bFoundBattery, bFoundAC
390 Dim sAssetTag, sSerialNumber, sMake, sModel, sProduct, sUUID, sMemory, sArchitecture, sProcessorSpeed, sCapableArchitecture
391
392 Dim sLenovoModel
393 Dim objResults, objInstance
394 Dim i
395 Dim bisX64, bIsUEFI, bSupportsSLAT, bSupportsX64, bSupportsX86
396
397
398 oLogging.CreateEntry "Getting asset info", LogTypeInfo
399
400
401 ' Get the SMBIOS asset tag from the Win32_SystemEnclosure class
402
403 Set objResults = objWMI.InstancesOf("Win32_SystemEnclosure")
404 bIsLaptop = false
405 bIsDesktop = false
406 bIsServer = false
407 For each objInstance in objResults
408
409 If objInstance.ChassisTypes(0) = 12 or objInstance.ChassisTypes(0) = 21 then
410 ' Ignore docking stations
411 Else
412
413 If not IsNull(objInstance.SMBIOSAssetTag) then
414 sAssetTag = Trim(objInstance.SMBIOSAssetTag)
415 End if
416 Select Case objInstance.ChassisTypes(0)
417 Case "8", "9", "10", "11", "12", "14", "18", "21"
418 bIsLaptop = true
419 Case "3", "4", "5", "6", "7", "15", "16"
420 bIsDesktop = true
421 Case "23"
422 bIsServer = true
423 Case Else
424 ' Do nothing
425 End Select
426
427 End if
428
429 Next
430 If sAssetTag = "" then
431 oLogging.CreateEntry "Unable to determine asset tag via WMI.", LogTypeInfo
432 End if
433
434
435 '/////////////////////////////////////////
436 ' Get the Lenovo Model Version from the Win32_ComputerSystemProduct class
437 ' Siva Mulpuru | 10:30 PM Monday, February 14, 2011
438 Set objResults = objWMI.ExecQuery("select * from Win32_ComputerSystemProduct")
439 For Each objInstance In objResults
440 sLenovoModel = objInstance.Version
441 Next
442 if sLenovoModel = "" then
443 oLogging.CreateEntry "Unable to determine LenovoModel tag via WMI.", LogTypeInfo
444 End if
445 '///////////////////////////////////////////
446 ' Get the serial number from the Win32_BIOS class.
447
448 Set objResults = objWMI.InstancesOf("Win32_BIOS")
449 For each objInstance in objResults
450
451 ' Get the serial number
452
453 If not IsNull(objInstance.SerialNumber) then
454 sSerialNumber = Trim(objInstance.SerialNumber)
455 End if
456
457 Next
458 If sSerialNumber = "" then
459 oLogging.CreateEntry "Unable to determine serial number via WMI.", LogTypeInfo
460 End if
461
462
463 ' Figure out the architecture from the environment
464
465 If oEnv("PROCESSOR_ARCHITEW6432") <> "" then
466 If UCase(oEnv("PROCESSOR_ARCHITEW6432")) = "AMD64" then
467 sArchitecture = "X64"
468 Else
469 sArchitecture = UCase(oEnv("PROCESSOR_ARCHITEW6432"))
470 End if
471 ElseIf UCase(oEnv("PROCESSOR_ARCHITECTURE")) = "AMD64" then
472 sArchitecture = "X64"
473 Else
474 sArchitecture = UCase(oEnv("PROCESSOR_ARCHITECTURE"))
475 End if
476
477
478
479 ' Get the processor speed from the Win32_Processor class.
480
481 bSupportsX86 = false
482 bSupportsX64 = false
483 bSupportsSLAT = false
484 Set objResults = objWMI.InstancesOf("Win32_Processor")
485 For each objInstance in objResults
486
487 ' Get the processor speed
488
489 If not IsNull(objInstance.MaxClockSpeed) then
490 sProcessorSpeed = Trim(objInstance.MaxClockSpeed)
491 End if
492
493
494 ' Determine if the machine supports SLAT (only supported with Windows 8)
495
496 On Error Resume Next
497 bSupportsSLAT = objInstance.SecondLevelAddressTranslationExtensions
498 On Error Goto 0
499
500
501 ' Get the capable architecture
502
503 If not IsNull(objInstance.Architecture) then
504 Select Case objInstance.Architecture
505 Case 0
506
507 ' If the processor is running a x86 OS, then there is *Still* the possibility that it can
508 ' support a x64 OS. We need to run a quick processor check to see if it supports x64.
509
510 bisX64 = FALSE
511 On Error Resume Next
512 bisX64 = oUtility.BDDUtility.Is64Bit
513 On Error Goto 0
514
515 If bisX64 = TRUE then
516 sCapableArchitecture = "AMD64 X64 X86"
517 bSupportsX86 = true
518 bSupportsX64 = true
519 Else
520 sCapableArchitecture = "X86"
521 bSupportsX86 = true
522 End if
523
524 Case 6
525 sCapableArchitecture = "IA64"
526 Case 9
527 sCapableArchitecture = "AMD64 X64 X86"
528 bSupportsX86 = true
529 bSupportsX64 = true
530 Case Else
531 SCapableArchitecture = "Unknown"
532 End Select
533 End if
534
535
536 ' Stop after first processor since all should match
537
538 Exit For
539
540 Next
541 If sProcessorSpeed = "" then
542 oLogging.CreateEntry "Unable to determine processor speed via WMI.", LogTypeInfo
543 End if
544 If sCapableArchitecture = "" then
545 oLogging.CreateEntry "Unable to determine capable architecture via WMI.", LogTypeInfo
546 End if
547
548 ' Get the product from the Win32_BaseBoard class
549
550 Set objResults = objWMI.InstancesOf("Win32_BaseBoard")
551 For each objInstance in objResults
552
553 If not IsNull(objInstance.Product) then
554 sProduct = Trim(objInstance.Product)
555 End if
556
557 Next
558 If sProduct = "" then
559 oLogging.CreateEntry "Unable to determine product via WMI.", LogTypeInfo
560 End if
561
562 ' Get the make, model, and memory from the Win32_ComputerSystem class
563
564 Set objResults = objWMI.InstancesOf("Win32_ComputerSystem")
565 For each objInstance in objResults
566
567
568 'MODIFIED CODE
569
570
571If not IsNull(objInstance.Manufacturer) then
572 sMake = Trim(objInstance.Manufacturer)
573 ' if sMake is an empty string, it means that the motherboard is made by Intel,
574 ' so I manually assign the value INTEL_ to sMake
575 If sMake= "" then
576 sMake = "INTEL_"
577 End if
578End if
579
580If not IsNull(objInstance.Model) then
581 sModel = Trim(objInstance.Model)
582
583 ' if sMake equals INTEL_, I change the value of sModel according to my needs
584 If sMake = "INTEL_" then
585 sModel = sProduct & "__"
586 End If
587
588End If
589
590 If not IsNull(objInstance.TotalPhysicalMemory) then
591 sMemory = Trim(Int(objInstance.TotalPhysicalMemory / 1024 / 1024))
592 End if
593
594 Next
595 If sMake = "" then
596 oLogging.CreateEntry "Unable to determine make via WMI.", LogTypeInfo
597 End if
598 If sModel = "" then
599 oLogging.CreateEntry "Unable to determine model via WMI.", LogTypeInfo
600 End if
601
602
603 ' Get the UUID from the Win32_ComputerSystemProduct class
604
605 Set objResults = objWMI.InstancesOf("Win32_ComputerSystemProduct")
606 For each objInstance in objResults
607
608 If not IsNull(objInstance.UUID) then
609 sUUID = Trim(objInstance.UUID)
610 End if
611
612 Next
613 If sUUID = "" then
614 oLogging.CreateEntry "Unable to determine UUID via WMI.", LogTypeInfo
615 End if
616
617
618 ' Determine if we are running UEFI
619
620 bIsUEFI = FALSE
621 On Error Resume Next
622 bIsUEFI = oUtility.BDDUtility.IsUEFI
623 On Error Goto 0
624
625
626 ' See if we are running on battery
627
628 If oEnv("SystemDrive") = "X:" and oFSO.FileExists("X:\Windows\Inf\Battery.inf") then
629
630 ' Load the battery driver
631
632 oShell.Run "drvload X:\Windows\Inf\Battery.inf", 0, true
633
634 End if
635
636 bFoundAC = False
637 bFoundBattery = False
638 Set objResults = objWMI.InstancesOf("Win32_Battery")
639 For each objInstance in objResults
640 bFoundBattery = True
641 If objInstance.BatteryStatus = 2 then
642 bFoundAC = True
643 End if
644 Next
645 If bFoundBattery and (not bFoundAC) then
646 bOnBattery = True
647 Else
648 bOnBattery = False
649 End if
650
651 oEnvironment.Item("AssetTag") = sAssetTag
652 oEnvironment.Item("SerialNumber") = sSerialNumber
653 oEnvironment.Item("Make") = sMake
654 oEnvironment.Item("Model") = sModel
655 oEnvironment.Item("LenovoModel") = sLenovoModel
656 oEnvironment.Item("Product") = sProduct
657 oEnvironment.Item("UUID") = sUUID
658 oEnvironment.Item("Memory") = sMemory
659 oEnvironment.Item("Architecture") = sArchitecture
660 oEnvironment.Item("ProcessorSpeed") = sProcessorSpeed
661 oEnvironment.Item("CapableArchitecture") = sCapableArchitecture
662 oEnvironment.Item("IsLaptop") = oUtility.ConvertBooleanToString(bIsLaptop)
663 oEnvironment.Item("IsDesktop") = oUtility.ConvertBooleanToString(bIsDesktop)
664 oEnvironment.Item("IsServer") = oUtility.ConvertBooleanToString(bIsServer)
665 oEnvironment.Item("IsUEFI") = oUtility.ConvertBooleanToString(bIsUEFI)
666 oEnvironment.Item("IsOnBattery") = oUtility.ConvertBooleanToString(bOnBattery)
667 oEnvironment.Item("SupportsX86") = oUtility.ConvertBooleanToString(bSupportsX86)
668 oEnvironment.Item("SupportsX64") = oUtility.ConvertBooleanToString(bSupportsX64)
669 If bSupportsSLAT or oEnvironment.Item("SupportsSLAT") = "" then
670 oEnvironment.Item("SupportsSLAT") = oUtility.ConvertBooleanToString(bSupportsSLAT)
671 Else
672 oLogging.CreateEntry "Property SupportsSLAT = " & oEnvironment.Item("SupportsSLAT"), LogTypeInfo
673 End if
674
675 oLogging.CreateEntry "Finished getting asset info", LogTypeInfo
676
677 GetAssetInfo = Success
678
679 End Function
680
681
682 '//---------------------------------------------------------------------------
683 '// Function: GetOSSKU()
684 '// Purpose: Get OS SKU details using WMI
685 '//---------------------------------------------------------------------------
686 Function GetOSSKU ()
687 Dim oInstance, oInstances,sOSVersion,sOperatingSystemSKU,sOSProductSuite,sSKU
688
689
690 oLogging.CreateEntry "Getting OS SKU info", LogTypeInfo
691
692
693 ' If in Windows PE then just exit
694
695 If oEnvironment.Item("OSVERSION") = "WinPE" Then
696 oLogging.CreateEntry "Unable to determine Windows SKU while in Windows PE.", LogTypeInfo
697 exit function
698 End If
699
700 If not (objWMI is Nothing) then
701
702 Set oInstances = objWMI.ExecQuery("select * from Win32_OperatingSystem")
703 For Each oInstance In oInstances
704 sOSVersion = oInstance.Version
705
706 If Left(sOSVersion,1) < "6" Then
707 sOSProductSuite = ""
708 on error resume next
709 sOSProductSuite = Cint(oInstance.OSProductSuite)
710 on error goto 0
711 Else
712 sOperatingSystemSKU = oInstance.OperatingSystemSKU
713 End If
714 Next
715 Else
716 oLogging.CreateEntry "Unable to obtain OS details since WMI is unavailable.", LogTypeInfo
717 End if
718
719 If sOperatingSystemSKU <> "" Then
720
721 Select Case sOperatingSystemSKU
722
723 Case "1"
724 sSKU = "ULTIMATE"
725 Case "2"
726 sSKU = "HOMEBASIC"
727 Case "3"
728 sSKU = "HOMEBASICPREMIUM"
729 Case "4"
730 sSKU = "ENTERPRISE"
731 Case "5"
732 sSKU = "HOMEBASICN"
733 Case "6"
734 sSKU = "BUSINESS"
735 Case "7"
736 sSKU = "SERVERSTANDARD"
737 Case "8"
738 sSKU = "SERVERDATACENTER"
739 Case "9"
740 sSKU = "SERVERSMALLBUSINESS"
741 Case "10"
742 sSKU = "SERVERENTERPRISE"
743 Case "11"
744 sSKU = "STARTER"
745 Case "12"
746 sSKU = "SERVERDATACENTERCORE"
747 Case "13"
748 sSKU = "SERVERSTANDARDCORE"
749 Case "14"
750 sSKU = "SERVERENTERPRISECORE"
751 Case "15"
752 sSKU = "SERVERENTERPRISEITANIUM"
753 Case "16"
754 sSKU = "BUSINESSN"
755 Case "17"
756 sSKU = "SERVERWEB"
757 Case "18"
758 sSKU = "SERVERCLUSTER"
759 Case "19"
760 sSKU = "SERVERHOME"
761 Case "20"
762 sSKU = "SERVERSTORAGEEXPRESS"
763 Case "21"
764 sSKU = "SERVERSTORAGESTANDARD"
765 Case "22"
766 sSKU = "SERVERSTORAGEWORKGROUP"
767 Case "23"
768 sSKU = "SERVERSTORAGEENTERPRISE"
769 Case "24"
770 sSKU = "SERVERFORSMALLBUSINESS"
771 Case "25"
772 sSKU = "SERVERSMALLBUSINESSPREMIUM"
773 Case "26"
774 sSKU = "HOMEPREMIUMN"
775 Case "27"
776 sSKU = "ENTERPRISEN"
777 Case "28"
778 sSKU = "ULTIMATEN"
779 Case "29"
780 sSKU = "SERVERWEBCORE"
781 Case "30"
782 sSKU = "MEDIUMBUSINESSSERVERMANAGEMENT"
783 Case "31"
784 sSKU = "MEDIUMBUSINESSSERVERSECURITY"
785 Case "32"
786 sSKU = "MEDIUMBUSINESSSERVERMESSAGING"
787 Case "33"
788 sSKU = "SERVERFOUNDATION"
789 Case "34"
790 sSKU = "SERVERHOMEPREMIUM"
791 Case "35"
792 sSKU = "SERVERFORSMALLBUSINESSV"
793 Case "36"
794 sSKU = "STANDARDSERVERV"
795 Case "37"
796 sSKU = "DATACENTERSERVERV"
797 Case "38"
798 sSKU = "ENTERPRISESERVERV"
799 Case "39"
800 sSKU = "DATACENTERSERVERCOREV"
801 Case "40"
802 sSKU = "STANDARDSERVERCOREV"
803 Case "41"
804 sSKU = "ENTERPRISESERVERCOREV"
805 Case "42"
806 sSKU = "HYPERV"
807 Case "43"
808 sSKU = "SERVERSTORAGEEXPRESSCORE"
809 Case "44"
810 sSKU = "SERVERSTORAGESTANDARDCORE"
811 Case "45"
812 sSKU = "SERVERSTORAGEWORKGROUPCORE"
813 Case "46"
814 sSKU = "SERVERSTORAGEENTERPRISECORE"
815 Case "47"
816 sSKU = "STARTERN"
817 Case "48"
818 sSKU = "PROFESSIONAL"
819 Case "49"
820 sSKU = "PROFESSIONALN"
821 Case "50"
822 sSKU = "SERVERSBSOLUTION"
823 Case "51"
824 sSKU = "SERVERFORSBSOLUTIONS"
825 Case "52"
826 sSKU = "STANDARDSERVERSOLUTIONS"
827 Case "53"
828 sSKU = "STANDARDSERVERSOLUTIONSCORE"
829 Case "54"
830 sSKU = "SBSOLUTIONSERVEREM"
831 Case "55"
832 sSKU = "SERVERFORSBSOLUTIONSEM"
833 Case "56"
834 sSKU = "SERVERSOLUTIONEMBEDDED"
835 Case "57"
836 sSKU = "SERVERSOLUTIONEMBEDDEDCORE"
837 Case "59"
838 sSKU = "ESSENTIALBUSINESSSERVERMGMT"
839 Case "60"
840 sSKU = "ESSENTIALBUSINESSSERVERADDL"
841 Case "61"
842 sSKU = "ESSENTIALBUSINESSSERVERMGMTSVC"
843 Case "62"
844 sSKU = "ESSENTIALBUSINESSSERVERADDLSVC"
845 Case "63"
846 sSKU = "SMALLBUSINESSSERVERPREMIUMCORE"
847 Case "64"
848 sSKU = "CLUSTERSERVERV"
849 Case "65"
850 sSKU = "EMBEDDED"
851 Case "66"
852 sSKU = "STARTERE"
853 Case "67"
854 sSKU = "HOMEBASICE"
855 Case "68"
856 sSKU = "HOMEPREMIUME"
857 Case "69"
858 sSKU = "PROFESSIONALE"
859 Case "70"
860 sSKU = "ENTERPRISEE"
861 Case "71"
862 sSKU = "ULTIMATEE"
863 Case "74"
864 sSKU = "PRERELEASE"
865 Case else
866 oLogging.CreateEntry "Unknown OS SKU = " & sOperatingSystemSKU, LogTypeInfo
867 End Select
868 End If
869
870 If sOSProductSuite <> "" Then
871
872 If sOSProductSuite AND 1 Then
873 sSKU = "SERVERSMALLBUSINESS"
874 ElseIF sOSProductSuite AND 2 Then
875 sSKU = "SERVERENTERPRISE"
876 ElseIF sOSProductSuite AND 4 Then
877 sSKU = "SERVERBACKOFFICE"
878 ElseIF sOSProductSuite AND 8 Then
879 sSKU = "SERVERCOMMUNICATIONSERVER"
880 ElseIF sOSProductSuite AND 32 Then
881 sSKU = "SERVERSMALLBUSINESS"
882 ElseIF sOSProductSuite AND 64 Then
883 sSKU = "EMBEDDED"
884 ElseIF sOSProductSuite AND 128 Then
885 sSKU = "SERVERDATACENTER"
886 ElseIF sOSProductSuite AND 512 Then
887 sSKU = "HOME"
888 ElseIF sOSProductSuite AND 1024 Then
889 sSKU = "SERVERWEB"
890 ElseIF sOSProductSuite AND 8192 Then
891 sSKU = "SERVERSTORAGESTANDARD"
892 ElseIF sOSProductSuite AND 16384 Then
893 sSKU = "SERVERCLUSTER"
894 Else
895 If oEnvironment.Item("IsServerOS") Then
896 sSKU = "SERVERSTANDARD"
897 Else
898 sSKU = "PROFESSIONAL"
899 End if
900 End IF
901
902 End If
903
904 oEnvironment.Item("OSSKU") = sSKU
905
906 oLogging.CreateEntry "Finished getting OS info", LogTypeInfo
907
908 GetOSSKU = Success
909
910 End Function
911
912 '//---------------------------------------------------------------------------
913 '// Function: GetCurrentOSInfo()
914 '// Purpose: Get Original OS details using WMI
915 '// Figure out the Original architecture of the environment, this is needed if you upgrade
916 '// from X86 to X64 to ensure the correct drivers is added/ deleted when ZTIDrivers run
917 '//---------------------------------------------------------------------------
918 Function GetCurrentOSInfo
919 Dim oAssocs
920 Dim Assoc
921
922 oLogging.CreateEntry "Determining the Disk and Partition Number from the Logical Drive " & oEnv("WinDir"), logTypeInfo
923
924 If oEnvironment.Item("OriginalArchitecture") = "" and oEnvironment.Item("OSVersion") <> "WinPE" Then
925 On Error Resume Next
926 oEnvironment.Item("OriginalArchitecture") = oEnvironment.Item("Architecture")
927
928 oUtility.SetTagForDrive oEnv("SystemDrive"), "OriginalPartitionIdentifier"
929
930 If oEnvironment.Item("OriginalWindir") = "" then
931 oEnvironment.Item("OriginalWindir") = oEnv("WinDir")
932 oLogging.CreateEntry "Note: OriginalWindir May change in the new OS, use OriginalDiskIndex and OriginalDiskPartition to determine real drive", logTypeInfo
933 End if
934 ElseIf oEnvironment.Item("OriginalArchitecture") = "" and oEnvironment.Item("OSVersion") = "WinPE" Then
935 For each oDrive in oFSO.Drives
936 If oDrive.DriveType = 2 then
937 If oDrive.IsReady Then
938 If oFSO.FolderExists(oDrive.DriveLetter & ":\Program Files (x86)") and oDrive.DriveLetter<>"X" then
939
940 oEnvironment.Item("OriginalArchitecture") = "X64"
941 Exit For
942 Else
943 If oFSO.FolderExists(oDrive.DriveLetter & ":\Program Files") and oDrive.DriveLetter<>"X" then
944 oEnvironment.Item("OriginalArchitecture") = "X86"
945 Exit For
946 Else
947 oEnvironment.Item("OriginalArchitecture") = ""
948 End If
949
950 End if
951 End If
952 End if
953 Next
954
955
956 End if
957
958 GetCurrentOSInfo = SUCCESS
959 End function
960
961
962 '//---------------------------------------------------------------------------
963 '// Function: GetNetworkInfo()
964 '// Purpose: Get network details using WMI
965 '//---------------------------------------------------------------------------
966 Function GetNetworkInfo
967
968 Dim iRetVal, objNetworkAdapters, objAdapter, sElement, sTmp1, arrTmp
969 Dim dicIPAddresses, dicMacAddresses, dicDefaultGateways
970
971
972 oLogging.CreateEntry "Getting network info", LogTypeInfo
973
974
975 ' Initialization
976
977 Set dicIPAddresses = CreateObject("Scripting.Dictionary")
978 Set dicMacAddresses = CreateObject("Scripting.Dictionary")
979 Set dicDefaultGateways = CreateObject("Scripting.Dictionary")
980
981 iRetVal = Success
982
983
984 ' Get a list of IP-enabled adapters
985
986 Set objNetworkAdapters = objWMI.ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled = 1")
987
988 For Each objAdapter In objNetworkAdapters
989
990 oLogging.CreateEntry "Checking network adapter: " & objAdapter.Caption, LogTypeInfo
991
992 ' Get the MAC address
993
994 If not dicMacAddresses.Exists(objAdapter.MacAddress) then
995 dicMacAddresses.Add objAdapter.MacAddress, ""
996 End if
997 oLogging.CreateEntry "MAC address = " & objAdapter.MacAddress, LogTypeInfo
998
999 ' Get the IP addresses
1000
1001 If not (IsNull(objAdapter.IPAddress)) then
1002 For each sElement in objAdapter.IPAddress
1003 If sElement = "0.0.0.0" or Left(sElement, 7) = "169.254" or sElement = "" then
1004 oLogging.CreateEntry "Ignoring IP Address " & sElement, LogTypeInfo
1005 Else
1006 If not dicIPAddresses.Exists(sElement) then
1007 dicIPAddresses.Add sElement, ""
1008 End if
1009 oLogging.CreateEntry "IP Address = " & sElement, LogTypeInfo
1010 End if
1011 Next
1012 End if
1013
1014 ' Get the default gateway values
1015
1016 If not (IsNull(objAdapter.DefaultIPGateway)) then
1017 For each sElement in objAdapter.DefaultIPGateway
1018 If sElement <> "" then
1019 If not dicDefaultGateways.Exists(sElement) then
1020 dicDefaultGateways.Add sElement, ""
1021 End if
1022 oLogging.CreateEntry "Default Gateway = " & sElement, LogTypeInfo
1023 End if
1024 Next
1025 End if
1026
1027 Next
1028
1029 oEnvironment.ListItem("IPAddress") = dicIPAddresses
1030 oEnvironment.ListItem("MacAddress") = dicMacAddresses
1031 oEnvironment.ListItem("DefaultGateway") = dicDefaultGateways
1032
1033 GetNetworkInfo = iRetVal
1034 oLogging.CreateEntry "Finished getting network info", LogTypeInfo
1035
1036 End Function
1037
1038
1039
1040 '//---------------------------------------------------------------------------
1041 '// Function: GetHAL
1042 '// Purpose: Get HAL details using WMI
1043 '//---------------------------------------------------------------------------
1044 Function GetHAL
1045
1046 Dim sHALName, sQueryString, objEntity, objEntities, oHAL
1047 Dim i
1048
1049
1050 oLogging.CreateEntry "Getting HAL information", LogTypeInfo
1051
1052
1053 ' First try to get the HAL name from WMI
1054
1055 sQueryString = "SELECT * FROM Win32_PnPEntity WHERE ClassGUID = '{4D36E966-E325-11CE-BFC1-08002BE10318}' or DeviceID LIKE 'ROOT\\%HAL%' "
1056
1057 On Error Resume Next
1058 Set objEntities = objWMI.ExecQuery( sQueryString )
1059 If Err then
1060 oLogging.CreateEntry "Unable to retrieve HAL via WMI: " & Err.Description & " (" & Err.Number & ")", LogTypeInfo
1061 Else
1062
1063 For each objEntity in objEntities
1064
1065 On Error Resume Next
1066 oHAL = oShell.RegRead( "HKLM\SYSTEM\CurrentControlSet\Enum\" & objEntity.DeviceID & "\HardwareID" )
1067 On error goto 0
1068
1069 sHALName = oHAL
1070 If IsArray(oHAL) then
1071 sHALName = oHAL(0)
1072 End if
1073
1074 Exit for
1075
1076 Next
1077
1078 End if
1079 On Error Goto 0
1080
1081
1082 ' If the HAL name is still blank, try to get it from the registry
1083
1084 If sHALName = "" then
1085
1086 For i = 0 to 9999
1087 On Error Resume Next
1088 sHALName = oShell.RegRead("HKLM\System\CurrentControlSet\Control\Class\{4D36E966-E325-11CE-BFC1-08002BE10318}\" & Right("000" & CStr(i), 4) & "\MatchingDeviceID")
1089 If Err then
1090 Exit For ' Found the last one
1091 End if
1092 On Error Goto 0
1093 Next
1094 End if
1095
1096 oEnvironment.Item("HALName") = sHALName
1097
1098 oLogging.CreateEntry "Finished getting HAL information", LogTypeInfo
1099
1100 End Function
1101
1102
1103
1104 '//---------------------------------------------------------------------------
1105 '// Function: GetDP
1106 '// Purpose: Get the name of the distribution share being used
1107 '//---------------------------------------------------------------------------
1108 Function GetDP
1109
1110 Dim sSMSDP
1111
1112
1113 oLogging.CreateEntry "Getting DP info", LogTypeInfo
1114
1115
1116 ' If OSD, get the DP server
1117
1118 sSMSDP = ""
1119 If oEnvironment.Item("_SMSTSBootImageID") <> "" and oEnvironment.Item("_SMSTSMediaType")<> "FullMedia" then
1120 Dim arrSMSDP,aSMSDP
1121
1122 ' Get the first path from the comma-delimited list
1123
1124 arrSMSDP = Split(oEnvironment.Item("_SMSTS" & oEnvironment.Item("_SMSTSBootImageID")),",")
1125 For Each aSMSDP in arrSMSDP
1126 If Instr(aSMSDP,"SMSPXEIMAGES$") = 0 Then
1127 sSMSDP = aSMSDP
1128 Exit For
1129 End If
1130 Next
1131
1132
1133 ' Figure out if it is a UNC or a URL, and extract the server name as appropriate
1134
1135 If Left(sSMSDP, 2) = "\\" then
1136 sSMSDP = Mid(sSMSDP, 3)
1137 sSMSDP = Left(sSMSDP, InStr(sSMSDP,"\")-1)
1138 ElseIf Left(sSMSDP, 7) = "http://" then
1139 sSMSDP = Mid(sSMSDP, 8)
1140 sSMSDP = Left(sSMSDP, InStr(sSMSDP,"/")-1)
1141 ElseIf Left(sSMSDP, 8) = "https://" then
1142 sSMSDP = Mid(sSMSDP, 9)
1143 sSMSDP = Left(sSMSDP, InStr(sSMSDP,"/")-1)
1144 End If
1145 End if
1146 If sSMSDP = "" and Left(oUtility.ScriptDir,2) = "\\" then
1147
1148 ' Assume we are running from a DP (maybe not always accurate, e.g. NewComputer phase)
1149
1150 sSMSDP = Mid(oUtility.ScriptDir,3)
1151 sSMSDP = Left(sSMSDP, InStr(sSMSDP,"\")-1)
1152
1153 End if
1154
1155 If sSMSDP = "" then
1156 oLogging.CreateEntry "Unable to determine ConfigMgr distribution point", LogTypeInfo
1157 Else
1158 oLogging.CreateEntry "ConfigMgr distribution point = " & sSMSDP, LogTypeInfo
1159 oEnvironment.Item("SMSDP") = sSMSDP
1160 End if
1161
1162 oLogging.CreateEntry "Finished getting DP info", LogTypeInfo
1163
1164 End function
1165
1166
1167 '//---------------------------------------------------------------------------
1168 '// Function: GetWDS
1169 '// Purpose: Get the name of the WDS server we may have booted from
1170 '//---------------------------------------------------------------------------
1171 Function GetWDS
1172
1173 Dim sCmd, sWDSServer
1174
1175
1176 oLogging.CreateEntry "Getting WDS server info", LogTypeInfo
1177
1178
1179 ' See if we can discover the WDS server name that we may have booted from
1180
1181 If oEnvironment.Item("OSVersion") = "WinPE" then
1182 On Error Resume Next
1183 sCmd = "wpeutil.exe UpdateBootInfo"
1184 oShell.Run sCmd, 0, true
1185 On Error Goto 0
1186 End if
1187
1188 sWDSServer = ""
1189 On Error Resume Next
1190 sWDSServer = oShell.RegRead("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\PEBootServerName")
1191 If Err then
1192 oLogging.CreateEntry "Unable to determine WDS server name, probably not booted from WDS.", LogTypeInfo
1193 Else
1194 oEnvironment.Item("WDSServer") = sWDSServer
1195 End if
1196 On Error Goto 0
1197
1198 oLogging.CreateEntry "Finished getting WDS server info", LogTypeInfo
1199
1200 End function
1201
1202 '//---------------------------------------------------------------------------
1203 '// Function: GetVirtualizationInfo()
1204 '// Purpose: Get virtualization details
1205 '//---------------------------------------------------------------------------
1206 Function GetVirtualizationInfo
1207
1208 Dim oInstance, oInstances
1209 Dim sVersionString
1210 Dim bIsVM, sVMPlatform
1211 Dim sVMHost, sVMName
1212
1213 oLogging.CreateEntry "Getting virtualization info", LogTypeInfo
1214
1215
1216 ' Set variables based on the capabilities of the hardware
1217
1218 oEnvironment.Item("IsHypervisorRunning") = oUtility.ConvertBooleanToString(oUtility.BDDUtility.IsHypervisorRunning)
1219 oEnvironment.Item("SupportsVT") = oUtility.ConvertBooleanToString(oUtility.BDDUtility.SupportsVT)
1220 oEnvironment.Item("SupportsNX") = oUtility.ConvertBooleanToString(oUtility.BDDUtility.SupportsNX)
1221 oEnvironment.Item("Supports64Bit") = oUtility.ConvertBooleanToString(oUtility.BDDUtility.Supports64Bit)
1222 If oUtility.BDDUtility.SupportsVT and oUtility.BDDUtility.SupportsNX and oUtility.BDDUtility.Supports64Bit then
1223 oEnvironment.Item("SupportsHyperVRole") = "True"
1224 Else
1225 oEnvironment.Item("SupportsHyperVRole") = "False"
1226 End if
1227
1228
1229 ' Determine what virtual machine environment this might be. Get the BIOS version information
1230
1231 Set oInstances = objWMI.ExecQuery("Select * from Win32_BIOS")
1232 For each oInstance in oInstances
1233 sVersionString = oInstance.Version
1234 Next
1235
1236
1237 ' Check the BIOS version information against known values
1238
1239 bIsVM = false
1240 sVMPlatform = ""
1241
1242 If oEnvironment.Item("Model") = "Virtual Machine" then
1243
1244 ' Microsoft virtualization technology detected, assign defaults
1245
1246 sVMPlatform = "Hyper-V"
1247 bIsVM = true
1248
1249
1250 ' Try to determine more specific values
1251
1252 Select Case sVersionString
1253 Case "VRTUAL - 1000831"
1254 bIsVM = true
1255 sVMPlatform = "Hyper-V Beta or RC0"
1256 Case "VRTUAL - 5000805", "BIOS Date: 05/05/08 20:35:56 Ver: 08.00.02"
1257 bIsVM = true
1258 sVMPlatform = "Hyper-V"
1259 Case "A M I - 2000622"
1260 bIsVM = true
1261 sVMPlatform = "VS2005R2SP1 or VPC2007"
1262 Case "A M I - 9000520"
1263 bIsVM = true
1264 sVMPlatform = "VS2005R2"
1265 Case "A M I - 9000816", "A M I - 6000901"
1266 bIsVM = true
1267 sVMPlatform = "Windows Virtual PC"
1268 Case "A M I - 8000314"
1269 bIsVM = true
1270 sVMPlatform = "VS2005 or VPC2004"
1271 End Select
1272
1273
1274 ' Try to get the VM host from the integration components
1275
1276 sVMHost = ""
1277 On Error Resume Next
1278 sVMHost = oShell.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Virtual Machine\Guest\Parameters\PhysicalHostNameFullyQualified")
1279 If Err then
1280 oLogging.CreateEntry "The VM physical host name was not found.", LogTypeVerbose
1281 Else
1282 oEnvironment.Item("VMHost") = sVMHost
1283 End if
1284 On Error Goto 0
1285
1286
1287 ' Try to get the VM namefrom the integration components
1288
1289 sVMName = ""
1290 On Error Resume Next
1291 sVMName = oShell.RegRead("HKEY_LOCAL_MACHINE\Software\Microsoft\Virtual Machine\Guest\Parameters\VirtualMachineName")
1292 If Err then
1293 oLogging.CreateEntry "The VM name was not found.", LogTypeVerbose
1294 Else
1295 oEnvironment.Item("VMName") = sVMName
1296 End if
1297 On Error Goto 0
1298
1299 ElseIf oEnvironment.Item("Model") = "VMware Virtual Platform" then
1300
1301 ' VMware detected
1302
1303 sVMPlatform = "VMware"
1304 bIsVM = true
1305
1306 ElseIf oEnvironment.Item("Model") = "VirtualBox" then
1307
1308 ' VirtualBox detected
1309
1310 bIsVM = true
1311 sVMPlatform = "VirtualBox"
1312
1313 ElseIf oEnvironment.Item("Make") = "Xen" then
1314
1315 ' Xen server detected
1316
1317 bIsVM = true
1318 sVMPlatform = "Xen"
1319
1320 Else
1321 oLogging.CreateEntry "This computer does not appear to be a virtual machine (BIOS is '" & sVersionString & "').", LogTypeInfo
1322 End if
1323
1324
1325 ' Set the appropriate variables
1326
1327 oEnvironment.Item("IsVM") = oUtility.ConvertBooleanToString(bIsVM)
1328 If sVMPlatform <> "" then
1329 oEnvironment.Item("VMPlatform") = sVMPlatform
1330 End if
1331
1332 oLogging.CreateEntry "Finished getting virtualization info", LogTypeInfo
1333
1334 End function
1335
1336
1337 '//---------------------------------------------------------------------------
1338 '// Function: GetBitLockerInfo()
1339 '// Purpose: Get BitLocker details
1340 '//---------------------------------------------------------------------------
1341 Function GetBitLockerInfo
1342
1343 Dim bIsBDE, objWMIBDE, colEnVol, objVol
1344 Dim iStatus, iPercent
1345
1346 bIsBDE = False
1347
1348 If oEnvironment.Item("OSCurrentBuild") >= "6000" then
1349
1350 ' Connect to the Bitlocker WMI object
1351
1352 On Error Resume Next
1353 Set objWMIBDE = GetObject("winmgmts:{impersonationLevel=impersonate,authenticationLevel=pktPrivacy}!root\cimv2\Security\MicrosoftVolumeEncryption" )
1354 If Err then
1355 oLogging.CreateEntry "MicrosoftVolumeEncryption namespace does not exist. BitLocker is not installed", LogTypeInfo
1356 Else
1357 oLogging.CreateEntry "Connection succeeded to MicrosoftVolumeEncryption", LogTypeInfo
1358
1359 On Error Goto 0
1360 Err.Clear
1361
1362
1363 ' Get the encryptable volumes. Check the conversion status on each
1364
1365 Set colEnVol = objWMIBDE.ExecQuery("Select * from Win32_EncryptableVolume")
1366 For each objVol in colEnVol
1367 objVol.GetConversionStatus iStatus, iPercent
1368 If iStatus <> 0 then
1369 If IsNull(objVol.DriveLetter) then
1370 oLogging.CreateEntry "Encrypted drive found: " & objVol.DeviceID & ", status = " & iStatus, LogTypeInfo
1371 Else
1372 oLogging.CreateEntry "Encrypted drive found: " & objVol.DriveLetter & ", status = " & iStatus, LogTypeInfo
1373 End if
1374 bIsBde = true
1375 End if
1376 Next
1377 If not bIsBde then
1378 oLogging.CreateEntry "There are no encrypted drives", LogTypeInfo
1379 End if
1380
1381 End if
1382 End if
1383
1384
1385 ' Set the IsBDE variable
1386
1387 oEnvironment.Item("IsBDE") = oUtility.ConvertBooleanToString(bIsBDE)
1388
1389 End function
1390
1391
1392 '//---------------------------------------------------------------------------
1393 '// Function: GetHostName
1394 '// Purpose: Record the current computer name
1395 '//---------------------------------------------------------------------------
1396 Function GetHostName
1397
1398 ' Get machine name
1399
1400 oEnvironment.Item("HostName") = oNetwork.ComputerName
1401
1402 End function
1403
1404
1405 '//----------------------------------------------------------------------------
1406 '// Rule processing routines
1407 '//----------------------------------------------------------------------------
1408
1409
1410 '//---------------------------------------------------------------------------
1411 '// Function: ProcessRules()
1412 '// Purpose: Get all settings that apply to the current workstation
1413 '//---------------------------------------------------------------------------
1414 Function ProcessRules(sIniFile, sSectionSettings)
1415
1416 Dim sRulePriority, arrRules
1417 Dim sElement, sNewSection, sRule
1418 Dim iRuleCount, iTotalRules
1419
1420
1421 ' Determine the rule priority
1422
1423 sRulePriority = oUtility.ReadIni(sIniFile, sSectionSettings, "Priority")
1424 If Len(sRulePriority) = 0 then
1425 oLogging.CreateEntry "ERROR - rule Priority key not set in section [" & sSectionSettings & "]", LogTypeError
1426 ProcessRules = Failure
1427 Exit Function
1428 End if
1429
1430 sRulePriority = UCase(sRulePriority)
1431 oLogging.CreateEntry "Using from [" & sSectionSettings & "]: Rule Priority = " & sRulePriority, LogTypeInfo
1432 arrRules = split(sRulePriority, ",", -1, 1)
1433
1434
1435 ' Process each search until all the required values are found
1436
1437 iTotalRules = UBound(arrRules) + 1
1438 For each sRule in arrRules
1439
1440 sRule = UCase(trim(sRule))
1441
1442 iRuleCount = iRuleCount + 1
1443 oLogging.ReportProgress "Processing rule: " & sRule, 50 + CInt(iRuleCount * 40.0 / iTotalRules)
1444
1445 If sRule = "DEFAULTGATEWAY" then
1446
1447 oLogging.CreateEntry "------ Processing the [" & sRule & "] section ------", LogTypeInfo
1448
1449 ' Check each default gateway value to see if a match can be found
1450 For each sElement in oEnvironment.ListItem(sRule)
1451
1452 sNewSection = oUtility.ReadIni(sIniFile, sSectionDefaultGateway, sElement)
1453 If sNewSection = "" then
1454 oLogging.CreateEntry "No match found for default gateway " & sElement & ".", LogTypeInfo
1455 Else
1456 oLogging.CreateEntry "Match found for default gateway " & sElement & ", retrieving settings.", LogTypeInfo
1457 iRetVal = GetIniGenericSettings(sIniFile, sNewSection)
1458 If iRetVal <> Success then
1459 oLogging.CreateEntry "ERROR trying to obtain ini settings for default gateway section " & sElement & ".", LogTypeError
1460 WScript.Quit iRetVal
1461 End if
1462 End if
1463
1464 Next
1465
1466 ElseIf dicLists.Exists(sRule) or oEnvironment.ListItem(sRule).Count > 0 then
1467
1468 For each sElement in oEnvironment.ListItem(sRule)
1469
1470 iRetVal = GetIniGenericSettings(sIniFile, sElement)
1471 If iRetVal <> Success then
1472 oLogging.CreateEntry "ERROR trying to obtain ini settings. No further processing.", LogTypeError
1473 WScript.Quit iRetVal
1474 End if
1475
1476 Next
1477
1478 ElseIf oEnvironment.Item(sRule) <> "" then
1479
1480 iRetVal = GetIniGenericSettings(sIniFile, CStr(oEnvironment.Item(sRule)))
1481 If iRetVal <> Success then
1482 oLogging.CreateEntry "ERROR trying to obtain ini settings. No further processing.", LogTypeError
1483 WScript.Quit iRetVal
1484 End if
1485
1486
1487 Else
1488
1489 iRetVal = GetIniGenericSettings(sIniFile, sRule)
1490 If iRetVal <> Success then
1491 oLogging.CreateEntry "ERROR trying to obtain ini settings. No further processing.", LogTypeError
1492 WScript.Quit iRetVal
1493 End if
1494
1495 End if
1496
1497 Next
1498
1499 oLogging.CreateEntry "------ Done processing " & sIniFile & " ------", LogTypeInfo
1500
1501 End Function
1502
1503
1504 '//---------------------------------------------------------------------------
1505 '// Function: GetProperties()
1506 '// Purpose: Get property names from rules INI file and gather XML file
1507 '//---------------------------------------------------------------------------
1508 Function GetProperties(sIniFile, sSectionSettings)
1509
1510 Dim iRetVal
1511
1512 Dim sGatherXML, oGatherXML, iRc
1513 Dim oNode, sElement, sType, sOverwrite
1514
1515 Dim bOEM, sSection
1516 Dim oEntries, sEntry
1517 Dim dicTmp, i
1518 Dim arrTmp
1519 Dim sProperty, oTmp, sTmp
1520
1521
1522 iRetVal = Success
1523
1524
1525 ' Check to see if this is an OEM scenario
1526
1527 If oFSO.FileExists(Left(oUtility.LogPath,1) & ":\MININT\OEM.VBS") then
1528 bOEM = true
1529 oEnvironment.Item("ZTISettings") = ""
1530 End if
1531
1532
1533 ' Read the XML file for a list of properties
1534
1535 iRc = oUtility.FindFile("ZTIGather.xml", sGatherXML)
1536 If iRc <> Success then
1537 oLogging.CreateEntry "Unable to locate ZTIGather.xml, skipping", LogTypeInfo
1538 Else
1539
1540 Set oGatherXML = CreateObject("MSXML2.DOMDocument")
1541 oGatherXML.load sGatherXML
1542
1543
1544 ' Process each node
1545
1546 For each oNode in oGatherXML.documentElement.selectNodes("property")
1547
1548 sElement = UCase(oNode.getAttribute("id"))
1549 sType = UCase(oNode.getAttribute("type"))
1550 sOverwrite = UCase(oNode.getAttribute("overwrite"))
1551
1552 If not dicProperties.Exists(sElement) then
1553 dicProperties.Add sElement, ""
1554 End if
1555
1556 If sType = "LIST" then
1557 If not dicLists.Exists(sElement) then
1558 dicLists.Add sElement, ""
1559 End if
1560 End if
1561
1562 If sOverwrite = "TRUE" then
1563 If not dicOverwrite.Exists(sElement) then
1564 dicOverwrite.Add sElement, ""
1565 End if
1566 End if
1567
1568 Next
1569
1570 End if
1571
1572
1573 ' Read the INI file for a list of properties
1574
1575 If oFSO.FileExists(sIniFile) then
1576
1577 Set oEntries = oUtility.SectionContents(sIniFile, sSectionSettings)
1578 For each sEntry in oEntries.Keys
1579
1580 Select Case sEntry
1581 Case "CustomKeysUserData", "CustomKeysSysprep", "OSDVariableKeys", "Properties"
1582
1583 ' Place each into the dictionary object (with its value, if available)
1584
1585 arrTmp = split(oEntries(sEntry), ",", -1, 1)
1586 For each sElement in arrTmp
1587
1588 sElement = uCase(trim(sElement))
1589
1590 If Right(sElement,3) = "(*)" then
1591 sElement = Left(sElement, Len(sElement)-3)
1592 If not dicLists.Exists(sElement) then
1593 dicLists.Add sElement, ""
1594 oLogging.CreateEntry "Added new custom list property " & sElement, LogTypeInfo
1595 End if
1596 End if
1597
1598 If not dicProperties.Exists(sElement) then
1599 dicProperties.Add sElement, ""
1600 oLogging.CreateEntry "Added new custom property " & sElement, LogTypeInfo
1601 End if
1602
1603 Next
1604
1605 End Select
1606
1607 Next
1608
1609 End if
1610
1611
1612 ' Check each property to make sure values exist in all environments (sync). ZTIUtility
1613 ' does the real work (see Public Property Get Item, Function GetDAT).
1614
1615 For each sProperty in dicProperties.Keys
1616
1617 If dicLists.Exists(sProperty) then
1618 Set oTmp = oEnvironment.ListItem(sProperty)
1619 Else
1620 sTmp = oEnvironment.Item(sProperty)
1621 End if
1622
1623 Next
1624
1625 GetProperties = iRetVal
1626
1627 End Function
1628
1629
1630 '//---------------------------------------------------------------------------
1631 '// Function: QuerySQL
1632 '// Purpose: Query SQL Server to obtain data for a particular rule
1633 '//---------------------------------------------------------------------------
1634 Function QuerySQL(sSection)
1635
1636 Dim oDatabase
1637
1638 Dim iRetVal, sElement, sColumn, objTmp, bFoundColumn, bFirst
1639 Dim objErr
1640 Dim oRS
1641
1642
1643 iRetVal = Success
1644
1645
1646 ' Create a database object
1647
1648 Set oDatabase = New Database
1649 oDatabase.IniFile = LocateINI
1650 oDatabase.SectionName = sSection
1651 If (oDatabase.Connect is Nothing) then
1652 oLogging.CreateEvent 41038, LogTypeError, "Unable to establish database connection using [" & sSection & "] properties.", Array()
1653 QuerySQL = Failure
1654 Exit Function
1655 End if
1656
1657
1658 ' Issue the SQL statement
1659
1660 Set oRS = oDatabase.Query
1661 If oRS is nothing then
1662 oLogging.CreateEvent 41039, LogTypeWarning, "Unable to execute database query.", Array()
1663 QuerySQL = Failure
1664 Exit Function
1665 ElseIf oRS.RecordCount = 0 then
1666 oRS.Close
1667 iRetVal = Success
1668 oLogging.CreateEntry "Record count from SQL = 0.", LogTypeInfo
1669 QuerySQL = iRetVal
1670 EXIT FUNCTION
1671 End if
1672
1673
1674 ' Process the results
1675
1676 oLogging.CreateEntry "Records returned from SQL = " & oRS.RecordCount, LogTypeInfo
1677 On Error Resume Next
1678 oRS.MoveFirst
1679 If Err then
1680 oLogging.CreateEntry "ERROR - Moving to first row (Error Number = " & Err.Number & ") (Error Description: " & Err.Description & ").", LogTypeError
1681 For each objErr in oDatabase.Connection.Errors
1682 oLogging.CreateEntry " ADO error: " & objErr.Description & " (Error #" & objErr.Number & "; Source: " & objErr.Source & "; SQL State: " & objErr.SQLState & "; NativeError: " & objErr.NativeError & ")", LogTypeError
1683 Next
1684 oRS.Close
1685 iRetVal = Failure
1686 Err.Clear
1687 QuerySQL = iRetVal
1688 EXIT FUNCTION
1689 End if
1690 On Error Goto 0
1691
1692 While not oRS.EOF
1693
1694 For each sElement in dicProperties.Keys
1695
1696 sColumn = oDatabase.TranslateToColumnID(sElement)
1697
1698
1699 ' Make sure the column exists in the recordset
1700
1701 bFoundColumn = False
1702 For each objTmp in oRS.Fields
1703 If Ucase(objTmp.Name) = Ucase(sColumn) then
1704 bFoundColumn = true
1705 Exit For
1706 End if
1707 Next
1708
1709 On Error Resume Next
1710
1711 If not bFoundColumn then
1712 ' oLogging.CreateEntry sColumn & " not found in the SQL table.", LogTypeInfo
1713 ElseIf IsNull(oRS.Fields(cStr(sColumn))) then
1714 ' oLogging.CreateEntry sColumn & " = NULL in SQL", LogTypeInfo
1715 ElseIf Len(oRS.Fields(cStr(sColumn))) = 0 then
1716 ' oLogging.CreateEntry sColumn & " = blank in SQL", LogTypeInfo
1717 Elseif dicLists.Exists(sElement) then ' Handle array
1718 Set objTmp = oEnvironment.ListItem(sElement)
1719 If not objTmp.Exists(oEnvironment.Substitute(oRS.Fields(cStr(sColumn)).Value)) then
1720 objTmp.Add oEnvironment.Substitute(oRS.Fields(cStr(sColumn)).Value), ""
1721 oEnvironment.ListItem(sElement) = objTmp
1722 oLogging.CreateEntry "Added " & sElement & " value from SQL: " & sColumn & " = " & oEnvironment.Substitute(oRS.Fields(cStr(sColumn)).Value), LogTypeInfo
1723 Else
1724 ' oLogging.CreateEntry "Value " & oRS.Fields(cStr(sColumn)).Value & " already found for " & sElement, LogTypeInfo
1725 End if
1726 ElseIf oEnvironment.Item(sElement) = "" or dicOverwrite.Exists(sElement) then
1727 oEnvironment.Item(sElement) = oEnvironment.Substitute(oRS.Fields(cStr(sColumn)).Value)
1728 oLogging.CreateEntry "Obtained " & sElement & " value from SQL: " & sColumn & " = " & oEnvironment.Item(sElement), LogTypeInfo
1729 ElseIf oEnvironment.Item(sElement) <> oEnvironment.Substitute(oRS.Fields(CStr(sColumn)).value) then
1730 oLogging.CreateEntry "Value for " & sElement & " is already set to " & oEnvironment.Item(sElement) & " so database value of " & oRS.Fields(cStr(sColumn)).Value & " will be ignored.", LogTypeInfo
1731 Else ' len(oEnvironment.Item(sElement) > 0
1732 ' oLogging.CreateEntry "Value for " & sElement & " is unchanged, database value of " & oRS.Fields(cStr(sColumn)).Value & " will be ignored.", LogTypeInfo
1733 End if
1734
1735 If Err then
1736 oRS.Close
1737 iRetVal = Failure
1738 oLogging.CreateEntry "ERROR obtaining " & sElement & " from recordset (Error Number = " & Err.Number & ") (Error Description: " & Err.Description & ").", LogTypeError
1739 Err.Clear
1740 QuerySQL = iRetVal
1741 EXIT FUNCTION
1742 End if
1743
1744 On Error Goto 0
1745
1746 Next
1747
1748 oRS.MoveNext
1749
1750 Wend
1751
1752
1753 oRS.Close
1754
1755 iRetVal = Success
1756 QuerySQL = iRetVal
1757
1758 End Function
1759
1760
1761 '//---------------------------------------------------------------------------
1762 '// Function: QueryWebService()
1763 '// Purpose: Query web service to obtain data
1764 '//---------------------------------------------------------------------------
1765 Function QueryWebService(sSection)
1766
1767 Dim oWebService
1768 Dim oResults
1769 Dim oNode
1770 Dim iRetVal, sElement, sColumn, objTmp
1771
1772
1773 iRetVal = Success
1774
1775
1776 ' Create a web service object
1777
1778 Set oWebService = New WebService
1779 If sSection <> "" then
1780 oWebService.IniFile = LocateINI
1781 oWebService.SectionName = sSection
1782 Else
1783 ' Handle the EventService special case
1784 oWebService.WebService = oEnvironment.Item("EventService") & "/MDTMonitorEvent/GetSettings?uniqueID=" & oEnvironment.Item("LTIGUID")
1785 oWebService.Method = "GET"
1786 oWebService.Quiet = True
1787 End if
1788
1789
1790 ' Make the web service call
1791
1792 On Error Resume Next
1793 Set oResults = oWebService.Query
1794 If oResults is Nothing then
1795 oLogging.CreateEntry "Web service returned no data.", LogTypeInfo
1796 QueryWebService = false
1797 Exit Function
1798 End if
1799 If oResults.DocumentElement is Nothing then
1800 oLogging.CreateEntry "Web service did not return a document element.", LogTypeInfo
1801 QueryWebService = false
1802 Exit Function
1803 End if
1804 On Error Goto 0
1805
1806
1807 ' Process the results
1808
1809 For each sElement in dicProperties.Keys
1810
1811 sColumn = oWebService.TranslateToColumnID(sElement)
1812
1813
1814 ' Make sure the column exists in the XML result
1815
1816 For each oNode in oResults.DocumentElement.SelectNodes("//*[translate(local-name(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz')='" & LCase(sColumn) & "']")
1817
1818 If oNode.childNodes.length = 1 then
1819 If (oNode.childNodes(0).nodeType = 3 or oNode.childNodes(0).nodeType = 4) then
1820
1821 If Len(oNode.Text) = 0 then
1822 ' oLogging.CreateEntry sColumn & " = blank, ignoring", LogTypeInfo
1823 Elseif dicLists.Exists(sElement) then ' Handle array
1824 Set objTmp = oEnvironment.ListItem(sElement)
1825 If not objTmp.Exists(oEnvironment.Substitute(oNode.Text)) then
1826 objTmp.Add oEnvironment.Substitute(oNode.Text), ""
1827 oEnvironment.ListItem(sElement) = objTmp
1828 oLogging.CreateEntry "Added " & sElement & " value from web service: " & sColumn & " = " & oEnvironment.Substitute(oNode.Text), LogTypeInfo
1829 Else
1830 ' oLogging.CreateEntry "Value " & oNode.Text & " already found for " & sElement, LogTypeInfo
1831 End if
1832 ElseIf oEnvironment.Item(sElement) = "" or dicOverwrite.Exists(sElement) then
1833 oEnvironment.Item(sElement) = oEnvironment.Substitute(oNode.Text)
1834 oLogging.CreateEntry "Obtained " & sElement & " value from web service: " & sColumn & " = " & oEnvironment.Item(sElement), LogTypeInfo
1835 ElseIf oEnvironment.Item(sElement) <> oEnvironment.Substitute(oNode.Text) then
1836 oLogging.CreateEntry "Value for " & sElement & " is already set to " & oEnvironment.Item(sElement) & " so database value of " & oNode.Text & " will be ignored.", LogTypeInfo
1837 Else ' len(oEnvironment.Item(sElement) > 0
1838 ' oLogging.CreateEntry "Value for " & sElement & " is unchanged, web service value of " & oNode.Text & " will be ignored.", LogTypeInfo
1839 End if
1840
1841 End if
1842 End if
1843
1844 Next
1845
1846 Next
1847
1848 QueryWebService = iRetVal
1849
1850 End Function
1851
1852
1853 '//---------------------------------------------------------------------------
1854 '// Function: GetIniGenericSettings()
1855 '// Purpose: Get data from the INI section specified
1856 '//---------------------------------------------------------------------------
1857 Function GetIniGenericSettings(sIniFile, sSection)
1858
1859 Dim iRetVal, sSectionExit, sSQLDefaultSection, sElement
1860 Dim sSQLDefault, sSQLServer, sDatabase, sTable
1861 Dim sSubsection, sValue, i, bSkipProperties
1862 Dim objTmp, sWebService
1863
1864
1865 iRetVal = Failure
1866
1867 bSkipProperties = false
1868
1869 oLogging.CreateEntry "------ Processing the [" & sSection & "] section ------", LogTypeInfo
1870
1871
1872 ' See if a user exit has been specified. If so, execute it.
1873
1874 sSectionExit = oUtility.ReadIni(sIniFile, sSection, "UserExit")
1875 If sSectionExit <> "" then
1876
1877 iRetVal = ProcessUserExit(sSectionExit, "SECTION", "BEFORE", sSection, bSkip)
1878 If iRetVal <> Success then
1879 oLogging.CreateEntry "ERROR returned from user exit. No further processing.", LogTypeError
1880 GetIniGenericSettings = Failure
1881 EXIT FUNCTION
1882 End if
1883 If bSkip then
1884 oLogging.CreateEntry "User exit requested to skip processing this section, exiting.", LogTypeInfo
1885 GetIniGenericSettings = Success
1886 EXIT FUNCTION
1887 End if
1888
1889 End if
1890
1891
1892 ' See if this is a database section. If so, process it.
1893
1894 sSqlServer = oUtility.ReadIni(sIniFile, sSection, "SQLServer")
1895 If sSqlServer <> "" then
1896
1897 bSkipProperties = true
1898 iRetVal = QuerySQL(sSection)
1899
1900 End if
1901
1902
1903 ' See if this is a web service section. If so, process it.
1904
1905 sWebService = oUtility.ReadIni(sIniFile, sSection, "WebService")
1906 If sWebService <> "" then
1907
1908 bSkipProperties = true
1909 iRetVal = QueryWebService(sSection)
1910
1911 End if
1912
1913
1914 ' See if a subsection has been specified. If so, recursively process it before doing the rest of this
1915 ' section.
1916
1917 sSubsection = oUtility.ReadIni(sIniFile, sSection, "Subsection")
1918 If sSubsection <> "" then
1919
1920 sSubsection = oEnvironment.Substitute(sSubsection)
1921 iRetVal = GetIniGenericSettings(sIniFile, sSubsection)
1922 If iRetVal <> Success then
1923 oLogging.CreateEntry "ERROR trying to obtain ini settings. No further processing.", LogTypeError
1924 WSCRIPT.QUIT iRetVal
1925 End if
1926
1927 End if
1928 sSqlDefault = oUtility.ReadIni(sIniFile, sSection, "SQLDefault")
1929 If sSqlDefault <> "" then
1930 sSubsection = oEnvironment.Substitute(sSqlDefault)
1931 iRetVal = GetIniGenericSettings(sIniFile, sSubsection)
1932 If iRetVal <> Success then
1933 oLogging.CreateEntry "ERROR trying to obtain ini settings. No further processing.", LogTypeError
1934 WSCRIPT.QUIT iRetVal
1935 End if
1936 End if
1937
1938
1939 ' Finally, process the entries in this section
1940
1941 If not bSkipProperties then
1942
1943 For each sElement in dicProperties.Keys
1944 If dicLists.Exists(sElement) then
1945 For i = 1 to 100
1946 sValue = oUtility.ReadIni(sIniFile, sSection, sElement & CStr(i))
1947 If Len(sValue) = 0 then
1948 sValue = oUtility.ReadIni(sIniFile, sSection, sElement & Right("000" & CStr(i), 3))
1949 End if
1950 If Len(sValue) = 0 then
1951 Exit For
1952 End if
1953 sValue = oEnvironment.Substitute(sValue)
1954 Set objTmp = oEnvironment.ListItem(sElement)
1955 If not objTmp.Exists(sValue) then
1956 objTmp.Add sValue, ""
1957 oEnvironment.ListItem(sElement) = objTmp
1958 oLogging.CreateEntry "Added value from [" & sSection & "]: " & sElement & " = " & sValue, LogTypeInfo
1959 End if
1960 Next
1961 Else
1962 sValue = oUtility.ReadIni(sIniFile, sSection, sElement)
1963 If Len(sValue) = 0 then
1964 ' oLogging.CreateEntry sElement & " value not defined in the section [" & sSection & "]", LogTypeInfo
1965 ElseIf Len(oEnvironment.Item(sElement)) = 0 or dicOverwrite.Exists(sElement) then
1966 oEnvironment.Item(sElement) = oEnvironment.Substitute(sValue)
1967 oLogging.CreateEntry "Using from [" & sSection & "]: " & sElement & " = " & oEnvironment.Item(sElement), LogTypeInfo
1968 End if
1969 End if
1970 Next
1971
1972 End if
1973
1974
1975 ' See if a user exit has been specified. If so, execute it.
1976
1977 sSectionExit = oUtility.ReadIni(sIniFile, sSection, "UserExit")
1978 If sSectionExit <> "" then
1979
1980 iRetVal = ProcessUserExit(sSectionExit, "SECTION", "AFTER", sSection, bSkip)
1981 If iRetVal <> Success then
1982 oLogging.CreateEntry "ERROR returned from user exit. No further processing.", LogTypeError
1983 GetIniGenericSettings = Failure
1984 EXIT FUNCTION
1985 End if
1986
1987 End if
1988
1989
1990 iRetVal = Success
1991 GetIniGenericSettings = iRetVal
1992
1993 End Function
1994
1995
1996 '//---------------------------------------------------------------------------
1997 '// Function: ProcessUserExit()
1998 '// Purpose: Call the specified user exit routine
1999 '//---------------------------------------------------------------------------
2000 Function ProcessUserExit(sFile, sType, sWhen, sDetail, bSkip)
2001
2002 Dim sFullFile, iRetVal
2003 Dim objExitScript, sExitScript
2004
2005
2006 On Error Resume Next
2007
2008 ' Make sure the specified exit file exists. If not, report an error.
2009
2010 iRetVal = oUtility.FindFile(sFile, sFullFile)
2011 If iRetVal <> Success then
2012 oLogging.CreateEntry "ERROR - User exit script file """ & sFile & """ not found.", LogTypeError
2013 ProcessUserExit = Failure
2014 EXIT FUNCTION
2015 End if
2016
2017
2018 ' Read the file
2019
2020 Set objExitScript = oFSO.OpenTextFile(sFullFile, 1, false)
2021 sExitScript = objExitScript.ReadAll
2022
2023
2024 ' Execute the text to dynamically add the function.
2025
2026 ExecuteGlobal sExitScript
2027 If Err then
2028 oLogging.CreateEntry "ERROR - Unable to parse the user exit script file: " & Err.Description & " (" & Err.Number & ")", LogTypeError
2029 ProcessUserExit = Failure
2030 EXIT FUNCTION
2031 End if
2032
2033
2034 ' Call the exit
2035
2036 bSkip = False
2037 iRetVal = UserExit(sType, sWhen, sDetail, bSkip)
2038 If Err then
2039 oLogging.CreateEntry "ERROR raised in User Exit: " & Err.Description & " (" & Err.Number & ")", LogTypeError
2040 ProcessUserExit = Failure
2041 EXIT FUNCTION
2042 ElseIf iRetVal <> Success then
2043 oLogging.CreateEntry "ERROR - User exit returned failure return value.", LogTypeError
2044 ProcessUserExit = Failure
2045 EXIT FUNCTION
2046 End if
2047
2048 oLogging.CreateEntry "User exit """ & sFullFile & """ called successfully, skip = " & bSkip & ".", LogTypeInfo
2049 ProcessUserExit = Success
2050
2051 End Function
2052
2053
2054 '//----------------------------------------------------------------------------
2055 '// Utility routines
2056 '//----------------------------------------------------------------------------
2057
2058
2059 '//---------------------------------------------------------------------------
2060 '// Function: SyncEnvironment
2061 '// Purpose: Make sure the task sequence environment has current values
2062 '//---------------------------------------------------------------------------
2063 Sub SyncEnvironment
2064
2065 '// Make sure the environment is in sync (VARIABLES.DAT vs. TS/OSD env)
2066
2067 oLogging.CreateEntry "Synchronizing the environments.", LogTypeInfo
2068
2069 If oEnvironment.GetDAT("DeployRoot") <> "" then
2070 oEnvironment.Item("DeployRoot") = oEnvironment.GetDAT("DeployRoot")
2071 End if
2072 If oEnvironment.GetDAT("DeployDrive") <> "" then
2073 oEnvironment.Item("DeployDrive") = oEnvironment.GetDAT("DeployDrive")
2074 End if
2075 If oEnvironment.GetDAT("ResourceRoot") <> "" then
2076 oEnvironment.Item("ResourceRoot") = oEnvironment.GetDAT("ResourceRoot")
2077 End if
2078 If oEnvironment.GetDAT("ResourceDrive") <> "" then
2079 oEnvironment.Item("ResourceDrive") = oEnvironment.GetDAT("ResourceDrive")
2080 End if
2081 If oEnvironment.GetDAT("OSDTargetDriveCache") <> "" then
2082 oEnvironment.Item("OSDTargetDriveCache") = oEnvironment.GetDAT("OSDTargetDriveCache")
2083 End if
2084
2085 oLogging.CreateEntry "Finished synchronizing the environments.", LogTypeInfo
2086
2087 End Sub
2088
2089
2090
2091 '//---------------------------------------------------------------------------
2092 '// Function: RemapVariables
2093 '// Purpose: Remap old variable names to new variable names
2094 '//---------------------------------------------------------------------------
2095 Function RemapVariables
2096
2097 oLogging.CreateEntry "Remapping variables.", LogTypeInfo
2098
2099
2100 'Provide mapping between BuildID and TaskSequenceID
2101
2102 If oEnvironment.Item("TaskSequenceID") = "" and oEnvironment.Item("BuildID")<>"" then
2103 oEnvironment.Item("TaskSequenceID") = Ucase(oEnvironment.Item("BuildID"))
2104 End if
2105
2106 If oEnvironment.Item("SkipTaskSequence") = "" and oEnvironment.Item("SkipBuild")<>"" then
2107 oEnvironment.Item("SkipTaskSequence") = oEnvironment.Item("SkipBuild")
2108 End if
2109 oEnvironment.Item("TaskSequenceID") = Ucase(oEnvironment.Item("TaskSequenceID"))
2110 oEnvironment.Item("DeploymentType") = Ucase(oEnvironment.Item("DeploymentType"))
2111 If UCase(oEnvironment.Item("BdeInstall")) = "NO" then
2112 oEnvironment.Item("BdeInstallSuppress") = "YES"
2113 End if
2114
2115 If oEnvironment.Item("JoinDomain") <> "" Then
2116 oEnvironment.Item("OSDNetworkJoinType") = "0"
2117 oEnvironment.Item("OSDDomainName") = oEnvironment.Item("JoinDomain")
2118
2119 If oEnvironment.Item("DomainAdmin") <> "" Then
2120 oEnvironment.Item("OSDJoinAccount") = oEnvironment.Item("DomainAdminDomain") & "\" & oEnvironment.Item("DomainAdmin")
2121 oEnvironment.Item("OSDJoinPassword") = oEnvironment.Item("DomainAdminPassword")
2122 End if
2123 If oEnvironment.Item("MachineObjectOU") <> "" Then
2124 oEnvironment.Item("OSDDomainOUName") = oEnvironment.Item("MachineObjectOU")
2125 End if
2126
2127 End if
2128
2129 If oEnvironment.Item("JoinWorkgroup") <> "" Then
2130 oEnvironment.Item("OSDNetworkJoinType") = "1"
2131 oEnvironment.Item("OSDWorkGroupName") = oEnvironment.Item("JoinWorkGroup")
2132 End if
2133
2134
2135 oLogging.CreateEntry "Finished remapping variables.", LogTypeInfo
2136
2137 End Function
2138
2139 '//---------------------------------------------------------------------------
2140 '// Function: LocateIni
2141 '// Purpose: Find the rules INI file specified or a default
2142 '//---------------------------------------------------------------------------
2143 Function LocateIni
2144
2145 Dim sIniFile
2146 Dim sFoundIniFile
2147
2148 oLogging.CreateEntry "Determining the INI file to use.", LogTypeInfo
2149
2150
2151 ' Get the command line values. If not specified, they will be blank.
2152
2153 If oEnvironment.Item("RulesFile") <> "" then
2154 sIniFile = oEnvironment.Item("RulesFile")
2155 Else
2156 sIniFile = oUtility.Arguments("inifile")
2157 End if
2158
2159
2160 ' Determine the INI file path and name
2161
2162 If Len(sIniFile) = 0 then
2163 iRetVal = oUtility.FindFile("CustomSettings.ini", sIniFile)
2164 If iRetVal = Success then
2165 oLogging.CreateEntry "Using DEFAULT VALUE: Ini file = " & sIniFile, LogTypeInfo
2166 End if
2167 Else
2168 If not oFSO.FileExists(sIniFile) then
2169 iRetVal = oUtility.FindFile(sIniFile, sFoundIniFile)
2170 If iRetVal = Success then
2171 sIniFile = sFoundIniFile
2172 Else
2173 oLogging.CreateEntry "Unable to locate " & sIniFile, LogTypeInfo
2174 sIniFile = ""
2175 End if
2176 Else
2177 oLogging.CreateEntry "Using COMMAND LINE ARG: Ini file = " & sIniFile, LogTypeInfo
2178 End if
2179 End if
2180
2181
2182 oLogging.CreateEntry "Finished determining the INI file to use.", LogTypeInfo
2183
2184
2185 ' Return the located file (this will be blank of none was found)
2186
2187 LocateIni = sIniFile
2188
2189 End Function
2190
2191
2192 '//---------------------------------------------------------------------------
2193 '// Function: KeyExists()
2194 '// Purpose: Tests to see if the specified registry key exists
2195 '//---------------------------------------------------------------------------
2196 Function KeyExists(sRegKey)
2197
2198 Dim ErrDesc(1)
2199
2200
2201 KeyExists = True
2202
2203 On Error Resume Next
2204
2205 oShell.RegRead(vbCR)
2206 ErrDesc(0) = Replace(Err.Description,vbCR,"")
2207 Err.Clear
2208
2209 oShell.RegRead(sRegKey)
2210 ErrDesc(1) = Replace(Err.Description,sRegKey,"")
2211 Err.Clear
2212
2213 If ErrDesc(0) = ErrDesc(1) Then KeyExists = False
2214
2215 End Function
2216
2217End Class
2218
2219 </script>
2220</job>