随笔 - 911  文章 - 5  评论 - 94  阅读 - 243万

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   momingliu11  阅读(802)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示