Looks like MDT 2012 and later has PowerShell support for task sequence
variables built-in. You should be able to do this with a simple two lines of
PowerShell code.

 

Import-Module -Name c:\minint\modules\ZTIUtility;

$TSEnv:OSDComputerName = 'FTSVM' + (Get-WmiObject -Class
Win32_BIOS).SerialNumber;

http://scriptimus.wordpress.com/2012/09/17/ltizti-powershell-accessing-task-
sequence-variables/ 

 

Cheers,

Trevor Sullivan

 

From: [email protected] [mailto:[email protected]]
On Behalf Of Marcum, John
Sent: Thursday, February 27, 2014 5:07 PM
To: [email protected]
Subject: [MDT-OSD] RE: MDT 2013 trying to automate naming of Hyper-V Client

 

On Error Resume Next

DIM Gateway(7)

strComputer = "."

 

set objTSEnvironment=CreateObject("Microsoft.SMS.TSEnvironment")

Set objWMIService=GetObject("winmgmts:" &
"{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colAdapters=objWMIService.ExecQuery ("SELECT * FROM
Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

Set colSerial=objWMIService.ExecQuery ("SELECT * FROM Win32_BIOS")

Set colBat=objWMIService.ExecQuery( "Select * from Win32_Battery")

Set colItems=objWMIService.ExecQuery("Select * From Win32_computersystem
where Model='VirtualBox' or Model='VMware Virtual Platform' or Model='Xen'
or Model='Virtual Machine'")

Set colUUIDItems=objWMIService.ExecQuery("Select * from
Win32_ComputerSystemProduct")

Set WshShell = CreateObject("WScript.Shell")

 

'Arrays

Gateway(1)="BHM,169.99.1.1,169.1692.1.1,169.1693.1.1,169.1694.1.1,169.1695.1
.1,169.1696.1.1,169.1697.1.1,169.1698.1.1,169.200.1.1,169.2169.1.1,169.255.0
.1"

Gateway(2)="CHR,169.64.1.1"

Gateway(3)="HSV,169.60.1.1"

Gateway(4)="MTG,169.61.1.1"

Gateway(5)="NSV,169.169.1690.1,169,17.0.1,169.18.0.1,169.169.169.0.1,169.17.
0.1,169.18.0.1,169.19.0.1,169.75.0.1,169.2.33.254"

Gateway(6)="WDC,169.65.1.1"

Gateway(7)="JKS,169.62.1.1"

 

Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI")   

ProgressUI.CloseProgressDialog 

 

'Getting Default Gateway

For Each objAdapter in colAdapters

   If Not IsNull(objAdapter.DefaultIPGateway) Then

      For i = 0 To UBound(objAdapter.DefaultIPGateway)

        strGateway=objAdapter.DefaultIPGateway(i)

        For a=1 to UBound(Gateway)

            If instr(Gateway(a),strGateway)<>0 Then

                strLoc=Left(Gateway(a),3)

                GetAltLocation

            End If

        Next

      Next

   End If

Next

 

'Getting Serial Number

For Each objSerial in colSerial

    strSerial=objserial.serialnumber

Next

 

'Checking for HW Type

strType="D"

strOSType="Windows7"

For Each objItem in colBat

    For Each objVMItem in colItems

        If objVMItem.model <> "VirtualBox" Then

            strType="L"

        End If

    Next

Next

 

'VM Specific Settings

For Each objItem in colItems

    If objitem.model="VMware Virtual Platform" Then

        strIsVMWare="yes"

    End If

    For Each UUIDItem in colUUIDItems

        strSerial=Right(UUIDitem.UUID,7)

        strType="V"

        strOSType="Windows7"

        ServerBuildCheck

    Next   

Next

 

If strType <> "V" Then

    If strType <> "S" Then

        ThinClientCheck

    End If

End If

 

'Setting OU Path

If strType="L" Then strOUPath="OU=Thick
Desktop,OU=Physical,OU=Computers,OU=Unified Desktop,DC=mydomain,DC=com"

If strType="D" Then strOUPath="OU=Thick
Desktop,OU=Physical,OU=Computers,OU=Unified Desktop,DC=mydomain,DC=com"

If strType="V" Then strOUPath="OU=Virtual,OU=Computers,OU=Unified
Desktop,DC=mydomain,DC=com"

If strType="S" Then strOUPath="OU=Deployment Testing,OU=Servers,OU=" &
strLoc & ",OU=BackEnd,DC=mydomain,DC=com"

If strType="T" Then strOUPath="OU=Desktops,OU=Computers,OU=" & strLoc &
",OU=FrontEnd,DC=mydomain,DC=com"

If strType="SD" Then
strOUPath="OU=SharedDesktops,OU=XenApp,OU=Citrix,OU=FrontEnd,DC=mydomain,DC=
com"

 

'Setting TS Variables

objTSEnvironment("Location")=strLoc

objTSEnvironment("SN")=strSerial

objTSEnvironment("HWType")=strType

If strType="SD" Then 

    objTSEnvironment("CompName")=strServerName

Else

    objTSEnvironment("CompName")=strLoc & "-" & strType & "-" & strSerial

End If

 

objTSEnvironment("OUPath")=strOUPath

objTSEnvironment("OSType")=strOSType

objTSEnvironment("VMWARE")=strIsVMWare

objTSEnvironment("SharedDesktop")=strIsSharedDesktop

 

'sub GetAltLocation

'Set WshShell = CreateObject("WScript.Shell")

'strTimeOut=WshShell.Popup("Will this machine be used at different
location?" & vbCrLf & "(This Message Will Close in 169 Seconds)", 169,
"Location Check", 4 + 32)

'    If strTimeOut=6 Then

'        strInput=InputBox("If this machine is NOT being built for " &
strLoc & vbCrLf & "Please enter the number from the list below" & vbCrLf &
"1. BHM" & vbCrLf & "2. CHR" & vbCrLf & "3. HSV" & vbCrLf & "4. JKS" &
vbCrLf & "5. MTG" & vbCrLf & "6. NSV" & vbCrLf & "7. WDC", "Alternate
Location Selction")

'        If IsNumeric(strInput)=0 Then

'            ErrorRoutine 

'        ElseIf strInput <> "" Then

'            If strInput < 8 Then

'                If strInput=1 Then strLoc="BHM"

'                If strInput=2 Then strLoc="CHR"

'                If strInput=3 Then strLoc="HSV"

'                If strInput=4 Then strLoc="JKS"

'                If strInput=5 Then strLoc="MTG"

'                If strInput=6 Then strLoc="NSV"

'                If strInput=7 Then strLoc="WDC"

'            Else

'                ErrorRoutine

'            End If

'        End If

'    End If

'End Sub

 

'Sub ErrorRoutine

'Set WshShell = CreateObject("WScript.Shell")

'strError=WshShell.Popup("You have not enetered a incorrect answer" & vbCrLf
& " Do you want to select again?" & vbCrLf & "(This Message Will Close in
169 Seconds)", 169, "Incorrect Selection Made", 4 + 32)

'If strError=6 Then

'    strInput=""

'    strError=""

'    GetAltLocation

'End If

'End Sub

 

'Sub ServerBuildCheck

'Set WshShell = CreateObject("WScript.Shell")

'    strServerTimeOut=WshShell.Popup("Virtual hardware has been detected." &
vbCrLf & "The default OS is Windows 7, would you like to change it to
Windows Server 2008 R2?" & vbCrLf & "(This Message Will Close in 15
Seconds)", 15, "Virtual Hardware Detected", 4 + 32)

'    If strServerTimeOut=6 Then

'        strType="S"

'        strOSType="Server"

'        strServerName=InputBox("Please enter a name for the new Server:",
"Server Name Prompt")

'        strIsSharedDesktop="no"

'        strSharedDesktopOU=msgbox("Will this machine be used as Citrix
Shared Desktop?",4,"Citrix Shared Desktop Prompt")

'        If strSharedDesktopOU=6 Then

'            strIsSharedDesktop="yes"

'            strType="SD" 

'        End If

'    End If

'End Sub

 

'Sub ThinClientCheck

'Set WshShell = CreateObject("WScript.Shell")

'    strServerTimeOut=WshShell.inputbox("Physical hardware has been
detected." & vbCrLf & "The default OS is Windows 7, would you like to change
it to Windows Thin PC?" & vbCrLf & "(Windows Thin PC is used for a thin
client host system" & vbCrLf & "(This Message Will Close in 15 Seconds)",
15, "Physical Hardware Detected", 4 + 32)

'    If strServerTimeOut=6 Then

'        strType="T"

'        strOSType="Thin"    

'    End If

'End Sub

 

  _____  

John Marcum
Lead Desktop Engineer

Bradley Arant Boult Cummings LLP

  _____  

 

From: [email protected] <mailto:[email protected]>
[mailto:[email protected]] On Behalf Of Charles Moore
Sent: Thursday, February 27, 2014 4:11 PM
To: [email protected] <mailto:[email protected]> 
Subject: [MDT-OSD] MDT 2013 trying to automate naming of Hyper-V Client

 

Fellow MDTers,

 

I am currently trying to automate the deployment of a Hyper-V client using
MDT 2013.  MY cs.ini has the following for VMWare..

 

[VMware, Inc.]

OSDComputerName=FTSVM#Right(replace("%SERIALNUMBER%"," ",""),8)#

 

Does anyone use now or no of the cs.ini entry for hyper-V, I've searched the
internet with no answer to this.

 

I am trying to use the schema of FTSVM%serialnumber% so FTSVM0123456 as an
example, FTSVM are static, and 123456 is the serial number populated from
the serial number of the Hyper-V.

 

 

 

  _____  


CONFIDENTIALITY NOTICE: This email message and any attachments hereto are
intended only for use by the addressee(s) named herein and may contain
information which is legally privileged, confidential and/or exempt from
disclosure under applicable law. If you are not the intended recipient, or
an authorized representative of the intended recipient, of this email
message, you are hereby notified that any review, dissemination,
distribution, copying, or use (including any reliance thereon) of this email
message, and/or any attachment hereto, is strictly prohibited.

Although this transmission and any attachments are believed to be free of
any virus or other defect that might affect any computer system into which
it is received and opened, it is the responsibility of the recipient to
ensure that it is free from virus or other defect and no responsibility is
accepted by the sending company, its subsidiaries and affiliates, as
applicable, for any loss or damage arising in any way from its use.

If you have received this email message in error, please immediately notify
the sender by return email and permanently delete from your system, the
original and any copies of this email and any attachments hereto and any
printout hereof. Unauthorized interception of this email is a violation of
federal criminal law.

  _____  


Confidentiality Notice: This e-mail is from a law firm and may be protected
by the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and
then delete it from your computer.

 

  _____  


Confidentiality Notice: This e-mail is from a law firm and may be protected
by the attorney-client or work product privileges. If you have received this
message in error, please notify the sender by replying to this e-mail and
then delete it from your computer.


Reply via email to