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%

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

在DeploymentShare\Scripts目录下新建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.29\DeploymentShare$\Custom\Files\Computersinfor.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.9\DeploymentShare$\Files\Computersinfor.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")

 

 

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

del C:\MININT\SMSOSD\OSDLOGS\VARIABLES.DAT /q
cscript ZTIGather.wsf /inifile:..\Control\CustomSettings.ini
"C:\Program Files (x86)\ConfigMgr 2007 Toolkit V2\Trace32.exe" c:\minint\smsosd\osdlogs\bdd.log  ;bdd.log里面可查看所有mdt中可用的变量,比如SerialNumber、Make、Model、MAC等

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

 

 

 

*************************************************************************************************************

根据地理位置,并以MAC地址为计算机名:

[Settings]
Priority=DefaultGateway,Default
Properties=MyCustomProperty,ComputerLocation

[DefaultGateway]
1.1.2.1=BJ
10.1.2.1=XA

[BJ]
ComputerLocation=BJ

[XA]
ComputerLocation=XA


[Default]
OSInstall=Y
SkipBDDWelcome=YES
SkipCapture=YES
SkipProductKey=YES
SkipComputerBackup=YES
SkipBitLocker=YES

;计算机名,去掉MAC地址中的冒号
SkipComputerName=NO
OSDComputername=%ComputerLocation%-#replace(right("%MACADDRESS001%",17),":","")#
;;;;;;;;;ComputerSerialNumber=#Left(“%SerialNumber%”,7)#

 

根据PC、笔记本、虚机自定义计算机名

[Settings]
Priority=Init, ByDesktop, ByLaptop, ByVirtual, Default
Properties=MyCustomProperty,ComputerSerialNumber, ComputerTypeName

[Init]
ComputerSerialNumber=#Right("%SerialNumber%",5)#

[ByLaptop]
Subsection=Laptop-%IsLaptop%

[ByDesktop]
Subsection=Desktop-%IsDesktop%

[ByVirtual]
Subsection=Virtual-%IsVM%

[Laptop-True] ComputerTypeName=L

[Desktop-True]
ComputerTypeName=D

[Virtual-True]
ComputerTypeName=V

 

posted on 2020-03-24 18:21  momingliu11  阅读(779)  评论(0编辑  收藏  举报