1.在DeploymentshareScripts下新建tv.ps1脚本,内容如下:
# Determine where to do the logging $TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $logPath = $TSenv.Value("LogPath") $logFile = "$logPath$($myInvocation.MyCommand).log" $TSenv.Value("ts01") = (gwmi win32_computersystem).manufacturer #自定义变量ts01 # Start the logging Start-Transcript $logFile Write-Host "Logging to2222 $logFile" $TSenv.Value("ts02") = “abc” # Stop logging Stop-Transcript
2.在CustomSettings.ini中添加自定义变量ts01
Properties=ComputerTypeName, ComputerSerialNumber,tv01
3.在TS中运行tv.ps1脚本,如下:
然后调用ps1中自定义的 ts01变量
===============================================================================================
通过.ps1脚本自定义计算机名:
tv.ps1脚本内容:
# Determine where to do the logging $TSenv = New-Object -COMObject Microsoft.SMS.TSEnvironment $logPath = $TSenv.Value("LogPath") $logFile = "$logPath$($myInvocation.MyCommand).log" # Start the logging Start-Transcript $logFile $TSenv.Value("OSDComputername")="abc" Import-Module ZTIUtility.psm1 #未生效 gci tsenv: |Out-File C:MININT est2.log #未生效 # Stop logging Stop-Transcript
2.将脚本放到Preinstall中,如下,CustomSettings.ini中无需其他设置,安装过程中默认的MINIT格式计算机名最后会被.ps1脚本中名称覆盖