Quantcast
Channel: Deployment Research - Johan Arwidmark
Viewing all articles
Browse latest Browse all 168

Creating the MDT 2012/2013 Deployment share using PowerShell

$
0
0

Here is a quick PowerShell example that shows you how to create a deployment share using PowerShell.

For those of you that are MDT savvy, you know that MDT has a View Script button option that allow you to see what PowerShell commands that MDT executes. Unfortunately, MDT sometimes lies to you, and the workbench will actually do more than the View Script button tells you.

Sample Script

Download zip (or copy and paste from below).

# Check for elevation
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
    [Security.Principal.WindowsBuiltInRole] "Administrator"))
{
    Write-Warning "Oupps, you need to run this script from an elevated PowerShell prompt!`nPlease start the PowerShell prompt as an Administrator and re-run the script."
    Write-Warning "Aborting script..."
    Break
}

# Validation OK, create MDT deployment share
$MDTServer = (get-wmiobject win32_computersystem).Name

Add-PSSnapIn Microsoft.BDD.PSSnapIn -ErrorAction SilentlyContinue 
New-Item -Path C:\MDTProduction\DS -ItemType Directory
new-PSDrive -Name "DS001" -PSProvider "MDTProvider" -Root "C:\MDTProduction\DS" -Description "MDT Production" -NetworkPath "\\$MDTServer\MDTProduction$" -Verbose | add-MDTPersistentDrive -Verbose
net share "MDTProduction$=C:\MDTProduction\DS" '/grant:EVERYONE,change'

# Create optional offline media
New-Item -Path C:\MDTProduction\ISO\Content\Deploy -ItemType Directory
new-item -path "DS001:\Media" -enable "True" -Name "MEDIA001" -Comments "" -Root "C:\MDTProduction\ISO" -SelectionProfile "Everything" -SupportX86 "False" -SupportX64 "True" -GenerateISO "True" -ISOName "MDTProduction.iso" -Verbose
new-PSDrive -Name "MEDIA001" -PSProvider "MDTProvider" -Root "C:\MDTProduction\ISO\Content\Deploy" -Description "MDT Production Offline Media" -Force -Verbose

 

/ Johan


More ...

Viewing all articles
Browse latest Browse all 168

Trending Articles