Overblog Tous les blogs Top blogs Technologie & Science Tous les blogs Technologie & Science
Editer l'article Suivre ce blog Administration + Créer mon blog
MENU

[MDT 2013] Autodeploy & Configure Silently MDT 2013 Update 2

Publié le par damcuvelier

#usage: <scriptname.ps1> [optional -sourcepath <path where you want to download sources] [optional -partdeploy <partitionwhere you want to install sources] 

 

# Set a var for the install source folder
param(
[Parameter(Mandatory=$false)][string]$sourcepath = "C:\Source",
[Parameter(Mandatory=$false)][string]$partdeploy = "D:"
)

$ErrorActionPreference = 'SilentlyContinue'

# This scripts needs unrestricted access
$error.clear
Set-ExecutionPolicy Unrestricted; if($Error.count -gt 0){Set-ExecutionPolicy Unrestricted -scope CurrentUser}
$error.clear

Write-Host "The setup takes around 30 minutes depending on your internet speed" -nonewline -ForegroundColor Green

# Download the setup files

#Check if folder exists, if not, create it
if (!(Test-Path $sourcepath)){New-Item $sourcepath -type directory | Out-Null}
if (!(Test-Path $partdeploy)){$partdeploy = "C:"}
 
# Check if file exists, if not, download it
 $adksetupexe = $sourcepath+"\adksetup.exe"
 $MDTSetupMSI = $sourcepath+"\MicrosoftDeploymentToolkit2013_x64.msi"
 
 
if (!(Test-Path $adksetupexe)){
#Download Windows Assessment and Deployment Kit (ADK)
        Write-Host "Downloading Windows Assessment and Deployment Kit (ADK) for Windows 8.1 Update .." -nonewline
        $clnt = New-Object System.Net.WebClient
        $url = "https://download.microsoft.com/download/6/A/E/6AEA92B0-A412-4622-983E-5B305D2EBE56/adk/adksetup.exe"
        $clnt.DownloadFile($url,$adksetupexe)
        Write-Host "done!" -ForegroundColor Green
 }
 

 if (!(Test-Path $MDTSetupMSI)){
 #Download MDT 2013 Update 2
        Write-Host "Downloading MDT 2013 Update 2.." -nonewline
        $clnt = New-Object System.Net.WebClient
        $url = "https://download.microsoft.com/download/3/0/1/3012B93D-C445-44A9-8BFB-F28EB937B060/MicrosoftDeploymentToolkit2013_x64.msi"
        $clnt.DownloadFile($url,$MDTSetupMSI)
        Write-Host "done!" -ForegroundColor Green

 }

# This installs the Feature .NET Framework
Import-Module ServerManager
Add-WindowsFeature as-net-framework

Start-Sleep -s 10

# This installs Windows Deployment Service
Import-Module ServerManager
Add-WindowsFeature WDS

Start-Sleep -s 10

# Install MDT 2013 Update 2

$PSScriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path

msiexec /qb /i "$sourcepath\MicrosoftDeploymentToolkit2013_x64.msi" | Out-Null

Start-Sleep -s 10

# Install ADK Deployment Tools, USMT, WinPE

Start-Process -FilePath "$sourcepath\adksetup.exe" -Wait -ArgumentList "/features OptionId.DeploymentTools OptionId.UserStateMigrationTool OptionId.WindowsPreinstallationEnvironment /norestart /quiet /ceip off "

Start-Sleep -s 20

 

# Configure MDT 2013
# Initialize
Add-PSSnapIn Microsoft.BDD.PSSnapIn -ErrorAction SilentlyContinue

# Constants
$Computer = get-content env:computername
$sourcepath = "$partdeploy\DeploymentShare"
$ShareName = "DeploymentShare$"
$NetPath = "\\$Computer\DeploymentShare$"
$MDTDescription = "Deployment Share"

# Make MDT Directory
mkdir "$sourcepath"

# Create MDT Shared Folder
$Type = 0
$objWMI = [wmiClass] 'Win32_share'
$objWMI.create($sourcepath, $ShareName, $Type)


# Create PS Drive for MDT
new-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "$sourcepath" -Description "$MDTDescription" -NetworkPath "$NetPath"  -Verbose | add-MDTPersistentDrive -Verbose

# Create OS Folders
new-item -path "DS001:\Operating Systems" -enable "True" -Name "Windows 8" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Operating Systems" -enable "True" -Name "Windows 7" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Operating Systems" -enable "True" -Name "Windows Server" -Comments "" -ItemType "folder" -Verbose

# Create Driver Folders

new-item -path "DS001:\Out-of-Box Drivers" -enable "True" -Name "Vm Ware" -Comments "" -ItemType "folder" -Verbose

new-item -path "DS001:\Out-of-Box Drivers" -enable "True" -Name "Windows 7 x86" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers" -enable "True" -Name "Windows 7 x64" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers" -enable "True" -Name "Windows 8 x64" -Comments "" -ItemType "folder" -Verbos


new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x86" -enable "True" -Name "Dell Inc." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x86" -enable "True" -Name "Hewlett Packard." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x86" -enable "True" -Name "Lenovo." -Comments "" -ItemType "folder" -Verbose

new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x64" -enable "True" -Name "Dell Inc." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x64" -enable "True" -Name "Hewlett Packard." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 7 x64" -enable "True" -Name "Lenovo." -Comments "" -ItemType "folder" -Verbose

new-item -path "DS001:\Out-of-Box Drivers\Windows 8 x64" -enable "True" -Name "Dell Inc." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 8 x64" -enable "True" -Name "Hewlett Packard." -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Out-of-Box Drivers\Windows 8 x64" -enable "True" -Name "Lenovo." -Comments "" -ItemType "folder" -Verbose


# Create Packages Folders
new-item -path "DS001:\Packages" -enable "True" -Name "Language Packs" -Comments "" -ItemType "folder" -Verbose

# Create TS Folders
new-item -path "DS001:\Task Sequences" -enable "True" -Name "Windows 2008" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Task Sequences" -enable "True" -Name "Windows 7" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Task Sequences" -enable "True" -Name "Windows 2012" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Task Sequences" -enable "True" -Name "Windows 8" -Comments "" -ItemType "folder" -Verbose

# Create Application Folders
new-item -path "DS001:\Applications" -enable "True" -Name "Reference Applications" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Applications" -enable "True" -Name "Core Applications" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Applications" -enable "True" -Name "Drivers" -Comments "" -ItemType "folder" -Verbose
new-item -path "DS001:\Applications" -enable "True" -Name "Optional" -Comments "" -ItemType "folder" -Verbose

# Create Selection Profiles
new-item -path "DS001:\Selection Profiles" -enable "True" -Name "WinPE x86" -Comments "" -Definition "<SelectionProfile><Include path=`"Out-of-Box Drivers\WinPE x86`" #/></SelectionProfile>" -ReadOnly "False" -Verbose
new-item -path "DS001:\Selection Profiles" -enable "True" -Name "WinPE x64" -Comments "" -Definition "<SelectionProfile><Include path=`"Out-of-Box Drivers\WinPE x64`" #/></SelectionProfile>" -ReadOnly "False" -Verbose

# Import Operating System Source Files
import-mdtoperatingsystem -path "DS001:\Operating Systems\Windows 7" -SourcePath "$partdeploy\Source\Operating Systems\Windows 7 Enterprise x64" -DestinationFolder "Windows 7 #Enterprise x64" -Verbose
import-mdtoperatingsystem -path "DS001:\Operating Systems\Windows 8" -SourcePath "$partdeploy\Source\Operating Systems\Windows 8 Enterprise x64" -DestinationFolder "Windows 8 #Enterprise x64" -Verbose

# Import Applications

Import-Module "C:\Program Files\Microsoft Deployment Toolkit\bin\MicrosoftDeploymentToolkit.psd1"
New-PSDrive -Name "DS001" -PSProvider MDTProvider -Root "$partdeploy\DeploymentShare"

import-MDTApplication -path "DS001:\Applications\Core Applications" -enable "True" -Name "java 8 update 131" -ShortName "Java" -Version "8 update 131" -Publisher "Oracle" -Language "en-US" -CommandLine "install.cmd" -WorkingDirectory ".\Applications\java 8 update 131" -ApplicationSourcePath "$partdeploy\Source\Applications\Core Applications\Java\Java-v7u21" -DestinationFolder "java 8 update 131" -Verbose
import-MDTApplication -path "DS001:\Applications\Core Applications" -enable "True" -Name "Adobe Reader XI" -ShortName "Adobe Reader" -Version "11.0.03" -Publisher "Adobe" -Language "En-Us" -CommandLine "install.cmd" -WorkingDirectory ".\Applications\Adobe Reader-v11.0.03" -ApplicationSourcePath "$partdeploy\Source\Applications\Core Applications\Adobe\Reader-v11.0.03" -DestinationFolder "Adobe\Reader-v11.0.03" -Verbose

import-MDTApplication -path "DS001:\Applications\Core Applications" -enable "True" -Name "Adobe Flash Player 11" -ShortName "Adobe Flash Player" -Version "11.7.700.202" -Publisher "Adobe" -Language "En-Us" -CommandLine "install.cmd" -WorkingDirectory ".\Applications\Adobe Flash Player 11" -ApplicationSourcePath "$partdeploy\Source\Applications\Core Applications\Adobe\FlashPlayer-v11.7.700.202" -DestinationFolder "Adobe\FlashPlayer-v11.7.700.202" -Verbose
import-MDTApplication -path "DS001:\Applications\Core Applications" -enable "True" -Name "Office 2012 x86" -ShortName "Office 2012 x86" -Version "15" -Publisher "Microsoft" -Language "sv-SE" -CommandLine "install.cmd" -WorkingDirectory ".\Applications\Office 2012" -ApplicationSourcePath "$partdeploy\Source\Applications\Core Applications\Office\SW_DVD5_Office_Professional_Plus_2012_W32_Swedish_MLF_X18-55189" -DestinationFolder "Office 2012 x86" -Verbose
import-MDTApplication -path "DS001:\Applications\Core Applications" -enable "True" -Name "Office 2010 x86" -ShortName "Office 2010 x86" -Version "14" -Publisher "Microsoft" -Language "sv-SE" -CommandLine "install.cmd" -WorkingDirectory ".\Applications\Office 2010" -ApplicationSourcePath "$partdeploy\Source\Applications\Core Applications\Office\SW_DVD5_Office_Professional_Plus_2010_W32_English_MLF_X16-52536" -DestinationFolder "Office 2010 x86" -Verbose

# Import Drivers

import-mdtdriver -path "DS001:\Out-of-Box Drivers\Vm Ware" -SourcePath "$partdeploy\Source\Drivers\VM-Ware\" -Verbose

# Create Task Sequence

import-mdttasksequence -path "DS001:\Task Sequences\Windows 7" -Name "Windows 7 x64" -Template "Client.xml" -Comments "" -ID "01" -Version "1.0" -OperatingSystemPath "DS001:\Operating Systems\Windows 7\Windows 7 ENTERPRISE in Windows 7 #Enterprise x64 install.wim" -FullName "Windows User" -OrgName "AddPro" -HomePage "about:blank" -Verbose
import-mdttasksequence -path "DS001:\Task Sequences\Windows 8" -Name "Windows 8 x64" -Template "Client.xml" -Comments "" -ID "02" -Version "1.0" -OperatingSystemPath "DS001:\Operating Systems\Windows 8\Windows 8 Enterprise in Windows 8 #Enterprise x64 install.wim" -FullName "Windows User" -OrgName "AddPro" -HomePage "about:blank" -Verbose


# Restart of server

Write-Host "The installation and configuration is done. You need to restart the server." -nonewline -ForegroundColor Green

 

Commenter cet article