Friday, March 22, 2013

Doing Custom Drive Configuration MDT without changing Task Sequence using PowerShell

This post elaborates on the MDTDB PowerShell module from Michael Niehaus link URL and configures the drives using PowerShell. it does this without altering the Task Sequence.

The key to this is using a few MDT database variables:

  • OSDPartitions0BOOTABLE=
  • OSDPartitions0FILESYSTEM=
  • OSDPartitions0QUICKFORMAT=
  • OSDPartitions0SIZE=
  • OSDPartitions0SIZEUNITS=
  • OSDPartitions0TYPE=
  • OSDPartitions0VOLUMELETTERVARIABLE=
  • OSDPartitions0VOLUMENAME=

This variables will overrule de standard drive configuration defined in the Task Sequence. MDT can configure a maximum of 2 partitions (per disk) using the database variables OSDPartitions0 and OSDPartitions1Field OSDPartitions0SIZE will define the partition size in units specified in OSDPartitions0SIZEUNITS, these can be MB, GB or %. When using % this will define the percentage of remaining diskspace so if partition 0 was defined as 40Gb the specification of 100 % will result in the allocation of 100% of the rest of the remaining disk space to that second partition.

this script will use DHCP exports as created by another script you can find on my blog , if no, by DHCP exported MAC address, can be found the script will ask for a MAC address. it will check the MAC address for validity and the script will ask you to create a new MDTcomputer object if the machine cannot be found.



##################################
#
# this deployscript automates MDT using the database
# It configures the disk configuration of a new or existing computer object
# Functionality based on MDT plugin developed by Michael Niehaus
# Build by Bas Huygen
# March 2013
# Version 0.1
#################################

# Clear relevant variables
Clear-Host
Clear-Variable -Name computer
Clear-Variable -Name LASTEXITCODE

# import the relevant powershell modules and snapins
Import-Module D:\PSdeployripts\MDTDB\MDTDB.psm1 -Verbose
Add-PSSnapIn Microsoft.BDD.PSSnapIn

# Declare variables
$ErrorActionPreference= "SilentlyContinue"
$DeployServer = "deploy.deploy.lan"
$SQLServer = "deploySQL.deploy.lan"
$SQLInstance = "SQLExpress"
$MDTDatabaseName = "MDTdb"
$DHCPexport = "\\DHCP01\D$\PSdeployripts\Exports\exportDHCP.txt"

# Make a connection to the MDT database
Connect-MDTDatabase -SQLServer $SQLServer\$SQLInstance -Database $MDTDatabaseName

# Function Get-MAC $computer used to fetch MAC address
Function Get-MAC ($computer){
$macstr = 0
$maccnv = 0
if(!(Test-Path $DHCPexport)){Write-Host "path $DHCPexport is not valid"
$macstr =Get-Content Env:\TEMP\maccache.txt |where{$_ -like "*$computer*"}}
if($macstr.length -eq 0){
$maccnv= Read-Host ("$computer not found in cache `nEnter the MAC adress
`nFormat is xx:xx:xx:xx:xx:xx");
write "$computer $maccnv" |Out-File Env:\TEMP\maccache.txt -Append

# check the retreived MAC adress for validity
if($maccnv.Replace(":","").Length -ne 12) {
do{
Write-Host "Found $computer in DHCP however it is not valid: $maccnv"
$maccnv = Read-Host "Please enter a valid MAC address format is xx:xx:xx:xx:xx:xx";
}while ($maccnv.Replace(":","").Length -ne 12)
}
write "$computer $maccnv" |Out-File Env:\TEMP\maccache.txt -Append
}
else{ Write-Host "Found $computer with $maccnv"}
return $maccnv }

# Function set drive config entered by user
Function Drive-Config ($computer,$mac){
$config = Read-Host ("Please enter drive configuration: `n
-----------------------------------------------------------------
Standard disk configuration (1 partition all space allocated) (s) `
One custom partition rest not configured (1) `n
Two custom partitions (2)`n
-----------------------------------------------------------------
Please enter a choice (1,2,s)")

Switch ($config) {
1 {Set-MDTComputer -id $mac -settings @{OSDPartitions="1";
OSDPartitions0BOOTABLE="TRUE";
OSDPartitions0FILESYSTEM="NTFS";
OSDPartitions0QUICKFORMAT="TRUE";
OSDPartitions0SIZE=(Read-Host "The amount of GB's of the first drive");
OSDPartitions0SIZEUNITS="GB";
OSDPartitions0TYPE="Primary";
OSDPartitions0VOLUMELETTERVARIABLE="Newdrive1";
OSDPartitions0VOLUMENAME="OSDisk"
OSDPartitions1BOOTABLE="";
OSDPartitions1FILESYSTEM="";
OSDPartitions1QUICKFORMAT="";
OSDPartitions1SIZE="";
OSDPartitions1SIZEUNITS="";
OSDPartitions1TYPE="";
OSDPartitions1VOLUMELETTERVARIABLE="";
OSDPartitions1VOLUMENAME=""} > $null
}
2 {Set-MDTComputer -id $mac -settings @{OSDPartitions="2";
OSDPartitions0BOOTABLE="TRUE";
OSDPartitions0FILESYSTEM="NTFS";
OSDPartitions0QUICKFORMAT="TRUE";
OSDPartitions0SIZE=(Read-Host "The amount of GB's of the first drive");
OSDPartitions0SIZEUNITS="GB";
OSDPartitions0TYPE="Primary";
OSDPartitions0VOLUMELETTERVARIABLE="Newdrive1";
OSDPartitions0VOLUMENAME="OSDisk"
OSDPartitions1BOOTABLE="FALSE";
OSDPartitions1FILESYSTEM="NTFS";
OSDPartitions1QUICKFORMAT="TRUE";
OSDPartitions1SIZE=(Read-Host "The amount of GB's of the second drive");
OSDPartitions1SIZEUNITS="GB";
OSDPartitions1TYPE="Primary";
OSDPartitions1VOLUMELETTERVARIABLE="Newdrive2";
OSDPartitions1VOLUMENAME="Data" } > $null
}
s {Set-MDTComputer -id $mac -settings @{OSDPartitions="";
OSDPartitions0BOOTABLE="";
OSDPartitions0FILESYSTEM="";
OSDPartitions0QUICKFORMAT="";
OSDPartitions0SIZE="";
OSDPartitions0SIZEUNITS="";
OSDPartitions0TYPE="";
OSDPartitions0VOLUMELETTERVARIABLE="";
OSDPartitions0VOLUMENAME=""
OSDPartitions1BOOTABLE="";
OSDPartitions1FILESYSTEM="";
OSDPartitions1QUICKFORMAT="";
OSDPartitions1SIZE="";
OSDPartitions1SIZEUNITS="";
OSDPartitions1TYPE="";
OSDPartitions1VOLUMELETTERVARIABLE="";
OSDPartitions1VOLUMENAME=""} > $null
}
}
}

Clear-Host
$computer = Read-Host "Please enter Computer name"
write "Starting deployscript for $computer"
$mac = Get-MAC $computer
If(!((Get-MDTComputer -macAddress $mac).OSDComputerName -eq $computer)){
if($macstr -eq 0){Get-MAC $computer}
$newMDTComp = Read-Host "Make a new MDT Computer object? (y/n)"
if($newMDTComp -eq "y"){
New-MDTComputer -macAddress $mac -dedeployription $computer -settings @{OSInstall="YES";OSDComputerName="$computer"} > $null
Drive-Config $computer ((Get-MDTComputer -macAddress $mac).ID)}exit
}
else{Drive-Config $computer ((Get-MDTComputer -macAddress $mac).ID)}


happy OSD-ing 


Wednesday, March 20, 2013

Getting started with Michael Niehaus’s MDT module

Michael Niehaus published his MDT PowerShell Database module on May 15, 2009.
URL: http://blogs.technet.com/b/mniehaus/archive/2009/05/15/manipulating-the-microsoft-deployment-toolkit-database-using-powershell.aspx
this plugin is an extension to the standard MDT plugins and modules. it is targeted to the MDT database opposite most other MDT plugin’s that are mainly created to help you to modify the deployment share and its contents.
Unfortunately Michaels own blog is not very helpful in the application of the module so in this post i would like to help you to get started.


Organization of the Functions

The plugins are grouped into 5 units: new- ,set- ,get- ,clear- and remove -MDT*
All create-able and settable MDT items are handled generally in the same way:
  1. retrieve the Object ID
  2. set the Object with the option: –settings
the –settings property's are set individually like –settings (OSInstall=”Yes”) or with a hash table like –settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}
The settings that can be used in the hash table are published on my blog on URL: http://negyuhsit.blogspot.nl/2013/03/mdt-computer-object-property-details.html
Each function group has the same kind of commands. let’s look at them right now.


New-MDT functions

The New-MDT*  group is the first group of all functions in this module. these functions are for the single purpose of the creation of MDT Objects
CommandType Name
----------- ----
Function New-MDTComputer
Function New-MDTLocation
Function New-MDTMakeModel
Function New-MDTPackageMapping
Function New-MDTRole
Syntax of New-MDTComputer: New-MDTComputer identifier –description OSDComputerName –settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}

the identifier variable deserves some extra clarification: as identifier of a MDT object the following items can be used; at least one of them has to be defined:

-assetTag           uses the assetTag as identifier                     example:  E123456
-macAddress     uses the MAC address as identifier             example:  00:12:34:56:78
-serialNumber  uses the serialnumber of the machine          example:  12345678
-UUID              uses the UUID as identifier                          example: 329800735698586629295641978511506172918 (more information about UUID’s can be found on this link)

Syntax of New-MDTLocation:  New-MDTLocation –name LocationName –gateways IPADDRESSGW1,IPADDRESSGW2 –settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}

Syntax of New-MDTMakeModel: New-MDTMakeModel –make Makename (example: HP, Dell) –model ModelName settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}

Syntax of New-MDTPackageMapping: New-MDTPackageMapping –ARPName –package used to create mapping to packages on external systems like SCCM

Syntax of New-MDTRole: New-MDTRole –name RoleName settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}


Set-MDT* and Get-MDT*

Of the next two groups Set-MDT* and Get-MDT* ,the first function is the one that realy does configure MDT Objects. they do this in the following way:
Get-MDT* –ID mdtitemID –settings @(objectitem1=”text”;objectitem2=”text”;objectitem3=”text”}
The second function (Get-MDT*) is mainly there to fetch MDT object and to extract their ID's to use them in a Set command.
The way to retrieve the object ID is done like this: (Get-MDTComputer -macAddress $mac).ID where the MAC address is in a format like nn:nn:nn:nn:nn but offcourse the other three object identifiers can also be used to retrieve the object ID.
Another way to retrieve the ID of an object is to open the MDT MMC and look for the object, the ID is found in the table and in the GUI Tabs:

image

CommandType Name
----------- ----
Function Set-MDTArray
Function Set-MDTComputer
Function Set-MDTComputerAdministrator
Function Set-MDTComputerApplication
Function Set-MDTComputerPackage
Function Set-MDTComputerRole
Function Set-MDTLocation
Function Set-MDTLocationAdministrator
Function Set-MDTLocationApplication
Function Set-MDTLocationPackage
Function Set-MDTLocationRole
Function Set-MDTMakeModel
Function Set-MDTMakeModelAdministrator
Function Set-MDTMakeModelApplication
Function Set-MDTMakeModelPackage
Function Set-MDTMakeModelRole
Function Set-MDTPackageMapping
Function Set-MDTRole
Function Set-MDTRoleAdministrator
Function Set-MDTRoleApplication
Function Set-MDTRolePackage
Function Set-MDTRoleRole

CommandType Name
----------- ----
Function Get-MDTArray
Function Get-MDTComputer
Function Get-MDTComputerAdministrator
Function Get-MDTComputerApplication
Function Get-MDTComputerPackage
Function Get-MDTComputerRole
Function Get-MDTLocation
Function Get-MDTLocationAdministrator
Function Get-MDTLocationApplication
Function Get-MDTLocationPackage
Function Get-MDTLocationRole
Function Get-MDTMakeModel
Function Get-MDTMakeModelAdministrator
Function Get-MDTMakeModelApplication
Function Get-MDTMakeModelPackage
Function Get-MDTMakeModelRole
Function Get-MDTRole
Function Get-MDTRoleAdministrator
Function Get-MDTRoleApplication
Function Get-MDTRolePackage
Function Get-MDTRoleRole

The Clear-MDT* group

This group functions generally the same like the  Get-MDT* group. just like that function, MDT objects are cleared like this: Clear-MDT* –ID MDTObjectID
CommandType Name
----------- ----
Function Clear-MDTArray
Function Clear-MDTComputerAdministrator
Function Clear-MDTComputerApplication
Function Clear-MDTComputerPackage
Function Clear-MDTComputerRole
Function Clear-MDTLocationAdministrator
Function Clear-MDTLocationApplication
Function Clear-MDTLocationPackage
Function Clear-MDTLocationRole
Function Clear-MDTMakeModelAdministrator
Function Clear-MDTMakeModelApplication
Function Clear-MDTMakeModelPackage
Function Clear-MDTMakeModelRole
Function Clear-MDTRoleAdministrator
Function Clear-MDTRoleApplication
Function Clear-MDTRolePackage
Function Clear-MDTRoleRole

Remove-MDT* group

This group is the opposite of the New_MDT* group: it removes MDT objects from the MDT database.
They function generally the same like the Set- and Get-MDT* groups. just like those functions the MDT object are removed like this: Remove-MDT* –ID MDTObjectID
CommandType Name
----------- ----
Function Remove-MDTComputer
Function Remove-MDTLocation
Function Remove-MDTMakeModel
Function Remove-MDTPackageMapping
Function Remove-MDTRole

All groups have some main functions like –verbose these are used for level of feedback to the user.

Tags van Technorati: ,,,,

Saturday, March 16, 2013

Understanding MDT OS deployments, doing automated LTI deployments, theory of Microsoft OS deployment

This is the Title of a book i publish on this page. It is a book about MDT in the way that it is used. So i will not elaborate on the installation of MDT nor will i provide you with a work instruction to replicate the things i have written.
My main goal here is to provide the reader the knowlegde and understanding he or she needs to get MDT do the things you want it to do.

The document is written from an IT implementor perspective, i will provide the reader basic knowledge about the workings of MDT as well as share advanced topics and solutions to get MDT to do things it cannot do 'out of the box'.
With the aid of PowerShell i managed to build a solution, with the information i share in this document, that has fully automated the Operating System Deployment of a client of mine. i hereby thank all internet sources i have mentioned in "Works Cited". So again:
Thank you:
And everyone i forgot to mention here for all the magnificent work you have done!

This is the first time is have published a work like this, if there are things to be shared or corrected, please let me know via a comment or email.

In advance thank you all and i wish the document and its users a merry future.

Here is the link to download the ebook, on this location also the scripts can be found.
http://sdrv.ms/ZyH49Q

Friday, March 15, 2013

MDT Computer Object Property Details

Doing a lot of research for a book about MDT i am writing i made a listing of all property details of a computer object in MDT (its database) because i did not find a list like this on the Internet i decided it could be useful for people using MDT, so here it is:

CmdLet

Purpose

ADDSLogPath

Path to store the AD database logs

ADDSPassword

Password for user chosen to run dcpromo

ADDSUserDomain

Domain for user chosen to run dcpromo

ADDSUserName

Domain for user chosen to run dcpromo

AdminPassword

Local Administrator password

ApplicationSuccessCodes

Space delimited list of error codes allowed by ZTIApplications.wsf (default: 0 3010)

AreaCode

Area code for the computers location.

AutoConfigDNS

Chooses to auto configure DNS

AutoMode

Sets AutoMode for Server 2003 deployments

AutoUsers

Sets AutoUsers for Server 2003 deployments

BackupDir

Directory on the network share where the computer backup should be stored.

BackupFile

Sets the name of the backup file used with ztibackup

BackupShare

Network share (UNC) where the computer backup should be stored.

BdeDriveLetter

Drive Letter for BDE partition (default S:).

BdeDriveSize

Drive size for BDE partition in MB (default 2048MB).

BdeInstall

Specifies the type of BDE install. (ProtectKeyWithTpm, ProtectKeyWithTpmAndPin, ProtectKeyWithTpmAndStartupKey, ProtectKeyWithExternalKey)

BdeInstallSuppress

Value to indicate whether a BDE Install should be attempted. (YES or NO)

BdeKeyLocation

Specifies the location of Key files (Fully qualified path or REMOVABLEDRIVE).

BdePin

Specifies the startup Pin for BDE (only valid with ProtectKeyWithTpmAndPin).

BdeRecoveryKey

Boolean (any value) creates a recovery key.

BDEWaitForEncryption

(Deprecated) Boolean (any value) indicated whether process should be held to wait for drive encryption to complete.

BitsPerPel

The color depth of the screen in bits per pixel (example: 32, default is OS Default).

BuildID

The BuildID of the Operating System

CaptureGroups

Specifies whether to capture the local group membership from the machine (default is YES; ALL can also be specified).

ChildName

Name of child domain

ComputerBackupLocation

Specifies where the computer backup should be stored (AUTO, NETWORK, NONE, specific path, default is AUTO).

ComputerName

This variable has been deprecated and should only be used for backwards compatibility.

ConfirmGC

Chooses whether to Confirm communication to GC

CountryCode

Country or region code to use for telephony.

CriticalReplicationOnly

Chooses to only replicate critical information

DatabasePath

Path to store the AD database

DestinationDisk

Used when multiple disks are used

DestinationPartition

Used when multiple disks are used

DHCPScopes

Number of DHCP Scopes to Configure

DHCPScopes0Description

Description for the first DHCP Scope

DHCPScopes0EndIP

Ending IP for the first DHCP Scope

DHCPScopes0ExcludeEndIP

End of the excluding IP range for the first DHCP Scope

DHCPScopes0ExcludeStartIP

Start of the excluding IP range for the first DHCP Scope

DHCPScopes0IP

IP Subnet for the first DHCP Scope

DHCPScopes0Name

Name for the first DHCP Scope

DHCPScopes0OptionDNSDomainName

DNS Domain Name for the first DHCP Scope

DHCPScopes0OptionDNSServer

DNS Server for the first DHCP Scope

DHCPScopes0OptionLease

Lease Duration for the first DHCP Scope

DHCPScopes0OptionNBTNodeType

NBT Node Type for the first DHCP Scope

DHCPScopes0OptionPXEClient

PXE Client for the first DHCP Scope

DHCPScopes0OptionRouter

Router of the excluding IP range for the first DHCP Scope

DHCPScopes0OptionWINSServer

WINS Server for the first DHCP Scope

DHCPScopes0StartIP

Starting IP address the first DHCP Scope

DHCPScopes0SubnetMask

Subnet mask for the first DHCP Scope

DHCPServerOptionDNSDomain

DNS domain for the DHCP Server Option

DHCPServerOptionDNSServer

DNS Server for the DHCP Server Option

DHCPServerOptionNBTNodeType

NBT NodeType for the DHCP Server Option

DHCPServerOptionPXEClient

PXE Client option for the DHCP Server Option

DHCPServerOptionRouter

Routers for the DHCP Server Option

DHCPServerOptionWINSServer

WINS Server for the DHCP Server Option

Dialing

Type of dialing to use for the telephony device in the computer, such as Tone or Pulse (XP only).

DNSServerOptionBINDSecondaries

Allows BIND secondaries

DNSServerOptionDisableRecursion

Disables recursion on the DNS server

DNSServerOptionEnableNetmaskOrdering

Enables netmask ordering

DNSServerOptionEnableRoundRobin

Enables Round Robin

DNSServerOptionEnableSecureCache

Enables cache security

DNSServerOptionFailOnLoad

Toggles fail on load

DNSServerOptionNameCheckFlag

Name Check Flag

DNSZones

Number of DNS Zones to Configure

DNSZones0DirectoryPartition

AD Partition to store the zone

DNSZones0FileName

File Name of the first DNS Zone

DNSZones0MasterIP

Primary IP for the zone

DNSZones0Name

Name of the first DNS Zone

DNSZones0Scavenge

Enables scavenging

DNSZones0Type

Type of Zone

DNSZones0Update

Enables dynamic updates

DoCapture

Flag to indicate that the machine should be Sysprepped and captured as a new WIM image (default is NO).

DomainAdmin

The name of the account used to join the domain.

DomainAdminDomain

The domain of the account used to join the domain.

DomainAdminPassword

The password of the account used to join the domain.

DomainLevel

Domain functional level

DomainNetBiosName

NetBios Name

DoNotCreateExtraPartition

When specified no extra partitions can be created

DriverGroup

Specifies the name of the driver group from which drivers should be injected

DriverSelectionProfile

Profile name used during driver installation.

EventShare

The UNC path where events for the management pack should be placed.

FinishAction

Specifies what action should be taken when a Lite Touch task sequence completes (SHUTDOWN, REBOOT, LOGOFF, or default of none)

ForestLevel

Forest Level

FullName

The full name that should be assigned to the computer.

Home_Page

Internet Explorer home page.

ID

Computer Object ID

InputLocale

Locale used for keyboard, e.g. 0409:00000409 (XP only, default is OS default).

JoinDomain

The name of the domain in which the computer should be placed.

JoinWorkGroup

The name of the workgroup in which the computer should be placed.

KeyboardLocale

Locale used for Keyboard, can be either 0409:00000409 or en-US format (Vista only, default is OS Default).

LoadStateArgs

Command line arguments for USMT Loadstate.

LongDistanceAccess

Number to dial to gain access to an outside line, such as 9.

MachineObjectOU

The OU in which the computer account should be created (if it does not already exist).

NewDomain

Choice between a new forest or new domain in an existing tree or a new domain in a new tree

NewDomainDNSName

DNS domain name of new domain

OrgName

The organization name that should be assigned to the computer.

OSDAdapter0DNSServerList

Comma delimited list of DNS Servers

OSDAdapter0DNSSuffix

DNS Suffix, example Frabrikam.com

OSDAdapter0EnableDHCP

If false, will disable DHCP, otherwise True (true if blank).

OSDAdapter0EnableDNSRegistration

True/False to enable DNS registration.

OSDAdapter0EnableFullDNSRegistration

True/False to enable FULL DNS registration.

OSDAdapter0EnableLMHOSTS

True/False to enable LMHosts

OSDAdapter0EnableTCPIPFiltering

False to enable TCP/IP Filtering.

OSDAdapter0EnableWINS

True/False to enable WINS

OSDAdapter0GatewayCostMetric

Comma delimited list of Gateway Cost Metrics as either integers, or the string Automatic (if empty, uses automatic)

OSDAdapter0Gateways

Comma delimited list of Gateway cost metrics

OSDAdapter0IPAddressList

Comma delimited list of IPAddress Lists

OSDAdapter0IPProtocolFilterList

Comma delimited list of IP Protocol FIlters

OSDAdapter0MacAddress

If present, match all settings to the adapter with this MAC address.

OSDAdapter0Name

If present, match all settings to the adapter with this name.

OSDAdapter0SubnetMask

Comma delimited list of Subnet masks

OSDAdapter0TCPFilterPortList

Comma delimited list of TCP Filters

OSDAdapter0TcpipNetbiosOptions

NetBIOS OPtions 1 or 0

OSDAdapter0UDPFilterPortList

Comma delimited list of UDP Filters

OSDAdapter0WINSServerList

Comma delimited list of WINS Servers

OSDAdapterCount

Number of Adapters defined here( either blank, 0 or 1)

OSDBitLockerCreateRecoveryPassword

Indicates whether a recovery password should be generated for AD.

OSDBitlockerMode

Specifies the type of BDE install. (KEY|TPMKey|TPMPin|TPM).

OSDBitLockerRecoveryPassword

Specifies the password to use for BDE Password scenarios

OSDBitLockerStartupKey

Specifies the value to use for startup key.

OSDBitLockerStartupKeyDrive

Specifies the location of Key files (Drive)

OSDBitLockerWaitForEncryption

Boolean (any value) indicated whether process should be held to wait for drive encryption to complete.

OSDComputerName

The new computer name to assign to the computer.

OSDDiskIndex

Disk index used for Partitioning (Default is 0)

OSDINSTALLPACKAGE

SCCM property; list of packages to be installed on the client

OSDINSTALLPROGRAM

SCCM property; program to be used for installation of the OSDINSTALLPACKAGE

OSDINSTALLSILENT

when specified True, the program installation will be totally silent

OSDMP

Management point to be used by SCCM

OSDNEWMACHINENAME

SCCM property; SCCM equivalent of OSDComputerName

OSDPartitions

Number of Partitions listed here (Default is None, max of 2, use Default configuration)

OSDPartitions0BOOTABLE

True/False - Is the partition bootalbe

OSDPartitions0FILESYSTEM

Type of File System (Default: NTFS, can be FAT32)

OSDPartitions0QUICKFORMAT

True/False - Shall the format be quick (default: True)

OSDPartitions0SIZE

Size of partition

OSDPartitions0SIZEUNITS

Size units of partition (default: MB, can be GB or percentage )

OSDPartitions0TYPE

Type of partition (Default: Primary, can be Logical or extended)

OSDPartitions0VOLUMELETTERVARIABLE

Variable Name to receive DriveLetter

OSDPartitions0VOLUMENAME

Volume name

OSDPartitions1BOOTABLE

True/False - Is the partition bootalbe (default: True if 1st partition)

OSDPartitions1FILESYSTEM

Type of File System (Default: NTFS, can be FAT32)

OSDPartitions1QUICKFORMAT

True/False - Shall the format be quick (default: True)

OSDPartitions1SIZE

Size of partition

OSDPartitions1SIZEUNITS

Size units of partition (default: MB, can be GB or percentage )

OSDPartitions1TYPE

Type of partition (Default: Primary, can be Logical or extended)

OSDPartitions1VOLUMELETTERVARIABLE

Variable Name to receive DriveLetter

OSDPartitions1VOLUMENAME

Volume name

OSDSITECODE

 

OSFeatures

Comma-delimited list of features to be installed

OSInstall

A flag to indicate that a new OS can be deployed to this computer, set to Y to authorize.

OSRoles

Comma-delimited list of role IDs to be installed

OSRoleServices

 

OverrideProductKey

Override product key (MAK key).

PackageSelectionProfile

Profile name used during Package installation.

ParentDomainDNSName

Parent DNS domain

ProductKey

Product key (non-MAK key).

ReplicaDomainDNSName

Replica DNS domain

ReplicaOrNewDomain

Chooses whether the domain controller will be a replica or part of a new domain

ReplicationSourceDC

DC used to replicate content

ResourceRoot

Specifies the name of a server to be used during the deployment process for resources like drivers, language packs, and hotfixes. (This should be set for ZTI only.)

Role

 

SafeModeAdminPassword

Password used for safemode recovery

ScanStateArgs

Command line arguments for USMT Scanstate.

ServerA

Specifies the name of a server to be used during the deployment process

ServerB

Specifies the name of a server to be used during the deployment process

ServerC

Specifies the name of a server to be used during the deployment process

SiteName

AD SiteName

SkipAdminPassword

Skip admin password

SkipApplications

Skip applications

SkipAppsOnUpgrade

Skips application installation on Upgrade scenario

SkipBDDWelcome

Skip the Lite Touch welcome screen shown when booting from a Lite Touch Windows PE image (default is NO)

SkipBitLocker

Skip the BitLocker pane

SkipBitLockerDetails

Skip the Bitlocker details

SkipBuild

Skip the Build

SkipCapture

Skip capture

SkipComputerBackup

Skip computer backup

SkipComputerName

Skip computer name

SkipDeploymentType

Skip DeploymentType

SkipDestinationDisk

Skip Destination Disk

SkipDomainMembership

Skip domain membership

SkipFinalSummary

Skip the final summary pane presented at the end of a Lite Touch deployment (default is NO)

SkipLocaleSelection

Skip locale selection

SkipPackageDisplay

Skip package display

SkipProductKey

Skip product key

SkipSummary

Skip summary pane

SkipTaskSequence

Skip the task sequence pane (requires that TaskSequenceID be set)

SkipTimeZone

Skip the time zone pane

SkipUserData

Skip user data

SkipWizard

Skip wizard

SLShare

The UNC path where logs should be copied.

SLShareDynamicLogging

Script log share where all MDT events should be written during execution (advanced debugging only)

SMSTSRunCommandLineUserName

Specifies the username (e.g. DOM\USER) that should be used with a Run Command Line action that is configure to run as user

SMSTSRunCommandLineUserPassword

Specifies the password that should be used with a Run Command Line action that is configure to run as user

SystemLocale

Locale used for System (default is OS Default).

SysVolPath

Path to store the SYSVOL

TaskSequenceID

TaskSequence ID used to automate LTI task sequence selection (default is blank)

TimeZone

The time zone identifier that should be used for the computer (XP only).

TimeZoneName

The time zone name that should be used for the computer (Vista only).

TpmOwnerPassword

Specifies the TPM Password for setting ownership.

Type

 

UDDir

The directory that should be created to contain the user data.

UDProfiles

A list of comma-separated usernames that should be captured.

UDShare

The UNC path where user data should be stored.

UILanguage

Default language used for OS before user is logged in, en-US format (default is OS Default).

UserDataLocation

Specifies where the user data should be stored (AUTO, NETWORK, NONE, specific path, default is AUTO).

UserDomain

The domain to be used to make network connections.

UserID

The user ID to be used to make network connections.

UserLocale

Locale used for Keyboard, can be either 0409:00000409 or en-US format (default is OS Default).

UserPassword

The password to be used to make network connections.

USMT3

Designates to always use USMT 3 Valid values are YES or NO.

USMTConfigFile

USMT configuration XML file that should be used when running Scanstate and Loadstate.

Vrefresh

VeThe vertical refresh rate of the monitor in Hz (example: 60, default is OS Default).

WDSServer

Name of the WDS server that should be used when installing WDS images (default is the server that contains the original image).

WipeDisk

Specifies whether the disk should be wiped. (Replace Only)

WizardSelectionProfile

Profile name used by the wizard for filtering the display of various items.

WsusServer

The URL of the WSUS server that should be used (optional, will use Windows Update or policy settings by default)

Xresolution

The horizontal resolution of the screen (example: 1024, default is OS Default).

Yresolution

The vertical resolution of the screen (example: 768, default is OS Default).

_SMSTSORGNAME

Customizes the Task Sequencer engine display banner.

Wednesday, March 13, 2013

Start MDT Litetouch Task Sequence remotely (psexec.exe revisited)

Recalling my blog of February 23 i used a PowerShell script to start a deployment of a MDT Litetouch task sequence remotely via the use of psexec.exe.

Addition sept13 2013: a GUI to wake machines is published here

image
This script pushes the litetouch.vbs script to the client using psexec.exe, as shown here.
Now after a few weeks i have had many tests with this script and i can tell you; it works! there are a few buts though!
Let’s look at the first version of the script:

$ErrorActionPreference = "SilentlyContinue"
Do {
Clear-Host
Do {
$trgMachine = Read-Host("Give the machinename that has to receive a LiteTouch deployment (Netbios or DNS name are equally good)")
      If($trgMachine -eq ""){Write-Host "Please give a name"}
}While($trgMachine -eq "")
      psexec.exe -i \\$trgMachine -h -u DOMAIN\User -p Userpassword cscript.exe //B "\\MDTServer\Deploymentshare$\Scripts\litetouch.vbs"
           if($LASTEXITCODE -eq 0){Write-Host "All went well"}else{Write-Host "Something went wrong: " + $LASTEXITCODE}
      $goOn= Read-Host("Another machine? (y)")

}while($goOn -eq "y")

this script will work quite well on older type of clients that are not to choosy about security (Windows clients older then Windows Vista) but on clients from Vista and above this script will only work when a user is logged on to the console; running it when no user is logged on will not result in very good deployments and running the script (started with a user account in the script) while an other user is logged on will also not do the trick. how do we solve this?
The trick is an option of psexec –i , this option calls an interactive process, when no SessionID is provided, psexec will run interactively in the console. when you enter a SessionID it will run in the provided session.
What i did is this: i took a function that checks for active sessions on the target machine, when no session is found mstsc is called to setup a session to the machine. In this session the deployment will run.


# thanks to http://adamstech.wordpress.com/2011/05/12/how-to-properly-pause-a-powershell-script/
Function Pause ($Message = "Press any key to continue . . . ") {
    If ($psISE) {
      
# The "ReadKey" functionality is not supported in Windows PowerShell ISE.
        $Shell = New-Object -ComObject "WScript.Shell"
        $Button = $Shell.Popup("Click OK to continue.", 0, "Script Paused", 0)

        Return
    }

    Write-Host -NoNewline $Message
    $Ignore =
        16,  # Shift (left or right)
        17,  # Ctrl (left or right)
        18,  # Alt (left or right)
        20,  # Caps lock
        91,  # Windows key (left)
        92,  # Windows key (right)
        93,  # Menu key
        144, # Num lock
        145, # Scroll lock
        166, # Back
        167, # Forward
        168, # Refresh
        169, # Stop
        170, # Search
        171, # Favorites
        172, # Start/Home
        173, # Mute
        174, # Volume Down
        175, # Volume Up
        176, # Next Track
        177, # Previous Track
        178, # Stop Media
        179, # Play
        180, # Mail
        181, # Select Media
        182, # Application 1
        183  # Application 2

    While ($KeyInfo.VirtualKeyCode -Eq $Null -Or $Ignore -Contains $KeyInfo.VirtualKeyCode) {
        $KeyInfo = $Host.UI.RawUI.ReadKey("NoEcho, IncludeKeyDown")
    }

    Write-Host
}


#Main procedureDO {Clear-Host
    # clear DNS to have the latest ip adresses   
Ipconfig /flushdns
        #enter a machine name
        Do  {$TargetMachine = Read-Host("Please enter the name of the Machine")
            If($TargetMachine -eq ""){Write-Host "That's no name, please try again"}
            }While($TargetMachine -eq "") 
    
  # Test for respons of machine
       
if(!(Test-Connection -Count 1 $TargetMachine)){ Write-Host "machine $TargetMachine is down"
             
               # Get the user session
               $loggedonuser = Get-WmiComputerSessions -computer $TargetMachine
                       if($loggedonuser.length -eq 0){write "No user is currently logged on `nChecking Operating System"
                            $OSType = (Get-WmiObject -ComputerName $TargetMachine Win32_OperatingSystem).Name
                            # checking the Operating System, if XP is found script version 1 can be used
                            # Else a RDP session will be started to be used by the litetouch.vbs script
                            if(!($OSType -like "*xp*")){
                                    $logonrdp = $TargetMachine + " /admin"
                                   # a session will be setup to the machine i use a rdp file here                                    mstsc /v:$logonrdp "D:\PSScripts\Logon scripts\Default.rdp"
                                  
# function pause is used to wait for the session to be fully running
                                    # thanks to
http://adamstech.wordpress.com/2011/05/12/how-to-properly-pause-a-powershell-script/
                                    Pause
                }}}

      # Now a sessionID will be fetched to be used by psexec       Write-Host "enumerating sessions"
       $SessionID = gwmi win32_process -computer $TargetMachine -Filter "Name = 'explorer.exe'"
       psexec.exe /accepteula  \\$TargetMachine -h -i $SessionID.SessionID -e -u DOMAIN\User -p password cscript.exe //Nologo //B "\\Deployserver\Deploymentshare$\Scripts\litetouch.vbs"
      # Depending on the exit codes the script will notify the user on success or failure       switch ($LASTEXITCODE)
       {
           0                   {Write-Host "All went well"}
           1                   {Write-Host "No user is logged on to the machine"}
           6                   {Write-Host "Machine $TargetMachine is not available"}
           53                  {Write-Host "The machine is restarted into WinPE to be deployed"}
           5206                {Write-Host "the deploy wizard could not finish"}
           -2147467259         {Write-Host "Litetouch generated arrors, check OSDLogs"}
            1073807364         {Write-Host "The machine is restarted into WinPE or the migratie went wrong"}
           -1073741510         {Write-Host "The machine is restarted into WinPE or the migratie went wrong"}
           default             {Write-Host "Something went wrong, the error is: " $LASTEXITCODE}
       } 
       Clear-Variable -Name OSType
$again= Read-Host("Do another machine (y)")
}while($again -eq "y")


i have tested the script on a lot of clients (XP and Windows 7 mixed), now you can service all these kind of Windows clients. till next time.



Thursday, March 07, 2013

Windows 8 AIK and MDT 2012

Just a simple report this time. when performing some IT duties on a Windows domain i needed a VAMT, i found out a new version (3.0) could be obtained by downloading Windows 8 AIK. so i did, went to download the setup and selected the management tools; in this proces i deselected the Windows Preinstallation components and installed the VAMT on my deploymentserver.

A day later i tried to update my WinPE bootfiles and invoked the command "Update Deployment Share" (forced) this failed. So i checked the properties of WinPE of the Deployment share: this crashed! throwing an error (sorry i do not have any detailed information about this because i did not collect it)

So it threw an error indicating 'unable to load .. from path D:\Windows 8 AIK\...\Windows Preinstallation...  aha! after looking at this path i found it to be not there.

I proved to be the omition of my WinPE components in the Windows 8 AIK setup.

conclusion: Windows 8 AIK integrates with MDT not mentioning it during setup. be aware about this.

till next time.

Tuesday, March 05, 2013

Wake sleeping Windows Machines with Wake on LAN and PowerShell

Waking a machine with the aid of PowerShell: there are quite some topics on this subject, for instance check these links: Andrew Morgan and Matthijs ten Seldam so i had the impression: nice!, i do not have to do that for myself. i was partially wrong. What happened? the scripts presented do work with input of some sort, in this case MAC addresses.
OK, let’s look at scripts that fetch this MAC addresses, cannot be hard right? i found these links: Fredrik Wall and Neolisk’s Tech Blog the one problem with these scripts is: you can only get a MAC address from running machines!? what about the situation where you want to wake machines that are asleep?
With that idea i started looking for other solutions. my thoughts were; what devices or services do store MAC adresses? answer DHCP! I came to this solution:

addition sept13 2013: a GUI to wake machines using this script has been published here
image

so i found this link to a great script: i took a part of it shown here:

Function TalkDHCP($server, $scope)
{
    #Run netsh for specific DHCP server
    $thearg = "dhcp server " + $server + " scope " + $scope + " show clients 1"
    $dhcp = ($thearg | netsh)

    #Take output, convert MacAddr - to : ... put in hash table
    #Modified from "Parsing columnar data" topic on
http://powershellcommunity.org forum
    $output = $dhcp[8..($dhcp.length-6)] | foreach {
    $row = $_.split(" ",[StringSplitOptions]::RemoveEmptyEntries)
    $ip = @{name="IP";expression={$row[0].trim()}}
    if ($row[-2].trim() -ne "-D-"){
    $mac = @{name="MAC";expression={$row[3].substring(1, 17).trim().replace("-",":").toUpper()}}
    }else{
    $mac = @{name="MAC";expression={$row[4].trim().replace("-",":").toUpper()}}
    }
    $machine = $row[-1].trim()
    $name = @{name="Name";expression={$machine.substring(0,$machine.indexOf("."))}}
    "" | select $ip,$mac,$name -ErrorAction SilentlyContinue
    }

    Write-Host "TALKED TO DHCP"
    Return $output | Select Name, Mac

}


talkdhcp 1.2.3.4  1.2.3.0


What this script does is extract Machine Names and MAC addresses from the DHCP server through the use of netsh
I saved this script on the server on which the DHCP server role is installed and installed it in the local scheduled task manager to be run every hour. The reason for this is: i am unable to invoke the script through a remote session… the output is written to a file on a share.

Here is the batch file that is fired by the Task Scheduler:

powershell.exe D:\PSSCripts\talktoDHCP.ps1 > D:\PSSCripts\exports\exportDHCP.txt

After the talktodhcp.ps1 script has run and an export is available on a share on the network. this can be used by another script to fire a WOL ‘magic packet’ for the creation of the magic packet i borrowed parts of the code of Andrew Morgan and combined with some of my own code to get it working:

function send-wakeonlan{
    param(
        [string]$mac)
    if (!($mac -like "*:*:*:*:*") -or ($mac -like "*-*-*-*-*")){
    write-error "mac address not in correct format"
    break
    }

    $string=@($mac.split(":""-") | foreach {$_.insert(0,"0x")})
    $target = [byte[]]($string[0], $string[1], $string[2], $string[3], $string[4], $string[5])

    $UDPclient = new-Object System.Net.Sockets.UdpClient
    $UDPclient.Connect(([System.Net.IPAddress]::Broadcast),4000)
    $packet = [byte[]](,0xFF * 102)
    6..101 |% { $packet[$_] = $target[($_%6)]}
    $UDPclient.Send($packet, $packet.Length) | out-null
}

#Main procedure
Do{
    Clear-Host
    $ErrorActionPreference=  "SilentlyContinue"
    $trgMachine = Read-Host("Give the name of the machine to be woken")
    $macstr = Get-Content '\\DHCPServer\D$\PSScripts\Exports\exportDHCP.txt' |where{$_ -like "*$trgMachine*"}
    $maccnv = $macstr.Substring($macstr.Length – 39, 17)
    send-wakeonlan -mac $maccnv     
        $i = 1
        do {($machup = Test-Connection -count 1 $trgMachine) | Out-Null
              Write $i; $i++; Start-Sleep -s 1 }
        until ($i -eq 30 -or $machup -notlike "")
     If($i -lt 30 -and $machup -notlike "" ){Write-Host "Machine $trgMachine has awoken"}
     else{Write-Host "Machine $trgMachine still sleeps"}
$another= Read-Host("Another machine ? (y)")
}while($another -eq "y")


that is it, now you can start machines that are sleeping, with the use of MAC addresses fed by DHCP. thank you and till next time!