zoukankan      html  css  js  c++  java
  • MDT通过PowerShell脚本自定义变量(自定义计算机名)

    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脚本中名称覆盖

  • 相关阅读:
    mysql优化思路
    mysql列类型选择
    mysql 多列索引的生效规则
    Myisam索引和Innodb索引的区别
    mysql创建远程用户并授权
    mysql 索引长度和区分度
    php 内存共享shmop源码阅读
    短链接系统的算法原理
    PHP die与exit的区别
    MySQL建立外键(Foreign Key)
  • 原文地址:https://www.cnblogs.com/dreamer-fish/p/13176812.html
Copyright © 2011-2022 走看看