MDT custom.ini自定义/查看变量

#根据笔记本、PC、虚机定义计算机名称
[Settings]
Priority=Init, ByLaptop, ByDesktop,ByVM,Default
Properties=ComputerTypeName, ComputerSerialNumber

[ByLaptop]
SubSection=Laptop-%IsLapTop%
ComputerTypeName=NB

[ByDesktop]
SubSection=Desktop-%IsDesktop%
ComputerTypeName=PC

[ByVM]
SubSection=VM-%IsVM%
ComputerTypeName=VM

[Default]
OSDComputer=E00-%ComputerTypeName%
========================================

[ByVM]
SubSection=VM-%IsVM%

[ByVM-True]
OSDComputer=VM

[ByVM-False] ;可选择否
OSDComputer=PHY

[Default]
OSDComputer=E00-%ComputerTypeName%

;OSDComputername=L-#GetCname()#-%ComputerTypeName%
;OSDComputername=L2-#GetCname2("%SerialNumber%")#-%ComputerTypeName%

========================================

在DeploymentShareScripts目录下新建UserExit.vbs脚本

[Default]
UserExit=UserExit.vbs
OSDComputername=L-#GetComputername()#-%ComputerTypeName%

附,UserExit.vbs脚本内容如下:

Function UserExit(sType, sWhen, sDetail, bSkip)
    oLogging.CreateEntry "entered UserExit ", LogTypeInfo
    UserExit = Success
End Function

'Function GetOfflineComputername()
'    GetOfflineComputername = "dddd"        
'End Function


'根据sn在csv中查找对应计算机名称,rules配置:OSDComputername=L-#GetCname()#-%ComputerTypeName%
Function GetCName()
    Const ForReading = 1
    Dim objFSO, objFile, csvFile, strline, strarr, sn
    csvFile = "\10.10.1.29DeploymentShare$CustomFilesComputersinfor.csv" '第一列sn,第二列computername
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If (objFSO.FileExists(csvFile)) Then    
        Set objFile = objFSO.OpenTextFile(csvFile, ForReading)

        Do Until objFile.AtEndOfStream  
            strline=objFile.readline  
            strarr=split(strline,",")
            sn= oEnvironment.Item("SerialNumber") '获取sn
            If  strarr(0) = sn Then
                CName=strarr(1) 
            End if

        Loop  
        objFile.close  
        Set fso = nothing

        If CName = Empty Then
            CName = "NLL"
        End if

    Else
        CName = "NLL"
    End if

    GetCName=CName '设置函数返回值
End Function



'根据sn在csv中查找计算机名称,rules配置需要添加外部参数如OSDComputername=L2-#GetCname2("%SerialNumber%")#-%ComputerTypeName%
Function GetCName2(sSN)
    Const ForReading = 1
    Dim objFSO, objFile, csvFile, strline, strarr, sn, CName
    csvFile = "\10.10.1.9DeploymentShare$FilesComputersinfor.csv" '第一列sn,第二列computername
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    If (objFSO.FileExists(csvFile)) Then     
        Set objFile = objFSO.OpenTextFile(csvFile, ForReading)

        Do Until objFile.AtEndOfStream  
            strline=objFile.readline  
            strarr=split(strline,",")
            If  strarr(0) = sSN Then
                CName=strarr(1) 
            End if
        Loop  
        objFile.close  
        Set fso = nothing

        If CName = Empty Then
            CName = "NLL"
        End if

    Else
        CName = "NLL"
    End if

    GetCName2=CName
    
End Function
'sSN= oEnvironment.Item("SerialNumber")
'msgbox GetCName2("6752-3479-8258-4172-6333-4772-912")

在DeploymentShareScripts目录下新建Testvariables.bat脚本,脚本内容如下:

del C:MININTSMSOSDOSDLOGSVARIABLES.DAT /q
cscript ZTIGather.wsf /inifile:..ControlCustomSettings.ini
"C:Program Files (x86)ConfigMgr 2007 Toolkit V2Trace32.exe" c:minintsmsosdosdlogsdd.log  ;bdd.log里面可查看所有mdt中可用的变量,比如SerialNumber、Make、Model、MAC等

运行Testvariables.bat脚本,可以查看mdt收集到的所有变量信息

原文地址:https://www.cnblogs.com/dreamer-fish/p/12560669.html