'######################################################################################### '# MICROSOFT LEGAL STATEMENT FOR SAMPLE SCRIPTS/CODE '######################################################################################### '# This Sample Code is provided for the purpose of illustration only and is not '# intended to be used in a production environment. '# '# THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY '# OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED '# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. '# '# We grant You a nonexclusive, royalty-free right to use and modify the Sample Code '# and to reproduce and distribute the object code form of the Sample Code, provided '# that You agree: '# (i) to not use Our name, logo, or trademarks to market Your software product '# in which the Sample Code is embedded; '# (ii) to include a valid copyright notice on Your software product in which '# the Sample Code is embedded; and '# (iii) to indemnify, hold harmless, and defend Us and Our suppliers from and '# against any claims or lawsuits, including attorneys’ fees, that arise '# or result from the use or distribution of the Sample Code. '######################################################################################### ' //*************************************************************************** ' // ***** Script Header ***** ' // ' // Solution: Custom Script for the Microsoft Deployment Toolkit ' // File: CUSTOM_SCCMVariables.vbs ' // Source: Deployment Guys - http://blogs.technet.com/deploymentguys ' // ' // Purpose: Write all deployment variables to a log file for debugging purposes ' // ' // Usage: cscript.exe CUSTOM_SCCMVariables.vbs ' // ' // History: ' // 0.1 Daniel Oxley 15/04/2010 Created initial script. ' // 0.2 Daniel Oxley 20/04/2010 Date/Time is appended to filename, allowing script to be launched multiple times ' // 0.3 Daniel Oxley 28/04/2010 Script now creates full folder path to log if it doesn't exist ' // ' // ***** End Header ***** ' //*************************************************************************** Const ForWriting = 2 Dim fso, oVar, oTSEnv, strLogFile, strComputer, strWinPath strComputer = "." Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") Set colOSItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem") Set fso = CreateObject("scripting.filesystemobject") For Each objOSItem In colOSItems strWinPath = objOSItem.WindowsDirectory Next If fso.FolderExists(strWinPath & "\System32\CCM\Logs") = False Then fso.CreateFolder(strWinPath & "\System32\CCM") fso.CreateFolder(strWinPath & "\System32\CCM\Logs") End If strLogFile = "CUSTOM_Variables_" & Replace(Replace(Date() & "-" & Time(), "/", "_"), ":", "_") & ".log" If fso.FileExists(strLogFile) = True Then fso.DeleteFile strLogFile, TRUE Set objTextFile = fso.OpenTextFile(strLogFile, ForWriting, True) Set oTSEnv = CreateObject("Microsoft.SMS.TSEnvironment") For Each oVar In oTSEnv.GetVariables objTextFile.WriteLine(oVar & ": " & oTSEnv(oVar)) Next objTextFile.Close