Deploy/Deploy_MDT_Server.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
Configuration DeployMDTServerContract
{
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSAvoidUsingCmdletAliases')]
    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseDeclaredVarsMoreThanAssignments')]

    Param(
        [Parameter(Mandatory=$true, HelpMessage = "Enter password for MDT Account")]
        [PSCredential]$Credentials
    )

    Import-Module -Name PSDesiredStateConfiguration, xSmbShare, cNtfsAccessControl, cMDTBuildLab
    Import-DscResource -ModuleName PSDesiredStateConfiguration
    Import-DscResource -ModuleName xSmbShare
    Import-DscResource -ModuleName cNtfsAccessControl
    Import-DscResource -ModuleName cMDTBuildLab

    node $AllNodes.Where{$_.Role -match "MDT Server"}.NodeName
    {
        LocalConfigurationManager {
            RebootNodeIfNeeded             = $AllNodes.RebootNodeIfNeeded
            ConfigurationMode              = $AllNodes.ConfigurationMode
            ConfigurationModeFrequencyMins = $AllNodes.ConfigurationModeFrequencyMins
            RefreshFrequencyMins           = $AllNodes.RefreshFrequencyMins
        }

        cMDTBuildPreReqs MDTPreReqs {
            DownloadPath = $Node.SourcePath
        }

        $DomainUser = ($Credentials.UserName).Split('\\')
        if ($DomainUser.Count -eq 1) {
            $MDTUserDomain = $Node.NodeName
            $MDTUserName = $Credentials.UserName
            User MDTAccessAccount {
              Ensure                 = "Present"
                UserName               = $MDTUserName
                FullName               = $MDTUserName
                Password               = $Credentials
                PasswordChangeRequired = $false
                PasswordNeverExpires   = $true
                Description            = "Managed Client Administrator Account"
                Disabled               = $false
            }
        }
        else {
            $MDTUserDomain = $DomainUser[0]
            $MDTUserName = $DomainUser[1]
        }

        WindowsFeature  DataDeduplication {
            Ensure = "Present"
            Name   = "FS-Data-Deduplication"
        }

        Package ADK {
            Ensure     = "Present"
            Name       = "Windows Assessment and Deployment Kit - Windows 10"
            Path       = "$($Node.SourcePath)\ADK\adksetup.exe"
            ProductId  = "3dec9467-d9ad-42df-8e84-888057bac8f1"
            Arguments  = "/Features OptionId.DeploymentTools /norestart /quiet /ceip off"
            ReturnCode = 0
        }

        Package WinPE {
            Ensure     = "Present"
            Name       = "Windows Assessment and Deployment Kit Windows Preinstallation Environment Add-ons - Windows 10"
            Path       = "$($Node.SourcePath)\WindowsPE\adkwinpesetup.exe"
            ProductId  = "d5163028-7863-4874-9e37-2284427b76fb"
            Arguments  = "/Features OptionId.WindowsPreinstallationEnvironment /norestart /quiet /ceip off"
            ReturnCode = 0
        }

        Package MDT {
            Ensure     = "Present"
            Name       = "Microsoft Deployment Toolkit (6.3.8456.1000)"
            Path       = "$($Node.SourcePath)\MDT\MicrosoftDeploymentToolkit_x64.msi"
            ProductId  = "2E6CD7B9-9D00-4B04-882F-E6971BC9A763"
            ReturnCode = 0
        }

        cMDTBuildDirectory DeploymentFolder {
            Name      = $Node.PSDrivePath.Replace("$($Node.PSDrivePath.Substring(0,2))\","")
            Path      = $Node.PSDrivePath.Substring(0,2)
            DependsOn = "[Package]MDT"
        }

        # Set FullAccess rights for MDT Deployment Share to Everyone
        $objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-1-0")
        $objUser = $objSID.Translate([System.Security.Principal.NTAccount])
        $userName = $objUser.Value
        xSmbShare FolderDeploymentShare {
            Ensure                = "Present"
            Name                  = $Node.PSDriveShareName
            Path                  = $Node.PSDrivePath
            FullAccess            = $userName
            FolderEnumerationMode = "AccessBased"
            DependsOn             = "[cMDTBuildDirectory]DeploymentFolder"
        }

        cMDTBuildPersistentDrive DeploymentPSDrive {
            Name        = $Node.PSDriveName
            Path        = $Node.PSDrivePath
            Description = $Node.PSDrivePath.Replace("$($Node.PSDrivePath.Substring(0,2))\","")
            NetworkPath = "\\$($Node.NodeName)\$($Node.PSDriveShareName)"
            DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
        }

        ForEach ($OSDirectory in $Node.OSDirectories) {
            [string]$OSVersion = ""
            $OSDirectory.GetEnumerator() | % {
                If ($_.key -eq "OperatingSystem") { $OSVersion = $_.value }
            }

            cMDTBuildDirectory $OSVersion.Replace(' ','') {
                Name        = $OSVersion
                Path        = "$($Node.PSDriveName):\Operating Systems"
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }

            cMDTBuildDirectory "TS$($OSVersion.Replace(' ',''))" {
                Name        = $OSVersion
                Path        = "$($Node.PSDriveName):\Task Sequences"
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        # Task Sequence folder for autobuild
        cMDTBuildDirectory "TSREF" {
            Name        = "REF"
            Path        = "$($Node.PSDriveName):\Task Sequences"
            PSDriveName = $Node.PSDriveName
            PSDrivePath = $Node.PSDrivePath
            DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
        }

        ForEach ($PkgFolder in $Node.PackagesFolderStructure) {
            [string]$Folder = ""
            $PkgFolder.GetEnumerator() | % {
                If ($_.key -eq "Folder") { $Folder = $_.value }
            }

            cMDTBuildDirectory "PKG$($Folder.Replace(' ',''))" {
                Name        = $Folder
                Path        = "$($Node.PSDriveName):\Packages"
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($CurrentApplicationFolder in $Node.ApplicationFolderStructure) {
            [string]$ApplicationFolder = ""
            $CurrentApplicationFolder.GetEnumerator() | % {
                If ($_.key -eq "Folder") { $ApplicationFolder = $_.value }
            }

            cMDTBuildDirectory "AF$($ApplicationFolder.Replace(' ',''))" {
                Name        = $ApplicationFolder
                Path        = "$($Node.PSDriveName):\Applications"
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }

            ForEach ($CurrentApplicationSubFolder in $CurrentApplicationFolder.SubFolders) {
                [string]$ApplicationSubFolder = ""
                $CurrentApplicationSubFolder.GetEnumerator() | % {
                    If ($_.key -eq "SubFolder") { $ApplicationSubFolder = $_.value }
                }

                cMDTBuildDirectory "ASF$($ApplicationSubFolder.Replace(' ',''))" {
                    Name        = $ApplicationSubFolder
                    Path        = "$($Node.PSDriveName):\Applications\$ApplicationFolder"
                    PSDriveName = $Node.PSDriveName
                    PSDrivePath = $Node.PSDrivePath
                    DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
                }
            }
        }

        ForEach ($SelectionProfile in $Node.SelectionProfiles) {
            [string]$Name        = ""
            [string]$Comments    = ""
            [string]$IncludePath = ""
            $SelectionProfile.GetEnumerator() | % {
                If ($_.key -eq "Name")        { $Name        = $_.value }
                If ($_.key -eq "Comments")    { $Comments    = $_.value }
                If ($_.key -eq "IncludePath") { $IncludePath = $_.value }
            }

            cMDTBuildSelectionProfile $Name.Replace(' ','') {
                Name        = $Name
                Comments    = $Comments
                IncludePath = $IncludePath
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($OperatingSystem in $Node.OperatingSystems) {
            [string]$Name       = ""
            [string]$Path       = ""
            [string]$SourcePath = ""

            $OperatingSystem.GetEnumerator() | % {
                If ($_.key -eq "Name")       { $Name       = $_.value }
                If ($_.key -eq "Path")       { $Path       = "$($Node.PSDriveName):\Operating Systems\$($_.value)" }
                If ($_.key -eq "SourcePath") { $SourcePath = "$($Node.SourcePath)\$($_.value)" }
            }

            cMDTBuildOperatingSystem $Name.Replace(' ','') {
                Name        = $Name
                Path        = $Path
                SourcePath  = $SourcePath
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($Application in $Node.Applications) {
            [string]$Name                  = ""
            [string]$Path                  = ""
            [string]$CommandLine           = ""
            [string]$ApplicationSourcePath = ""

            $Application.GetEnumerator() | % {
                If ($_.key -eq "Name")                  { $Name                  = $_.value }
                If ($_.key -eq "Path")                  { $Path                  = "$($Node.PSDriveName):$($_.value)" }
                If ($_.key -eq "CommandLine")           { $CommandLine           = $_.value }
                If ($_.key -eq "ApplicationSourcePath") { $ApplicationSourcePath = "$($Node.SourcePath)\$($_.value)" }
            }

            cMDTBuildApplication $Name.Replace(' ','') {
                Name                  = $Name
                Path                  = $Path
                CommandLine           = $CommandLine
                ApplicationSourcePath = $ApplicationSourcePath
                Enabled               = "True"
                PSDriveName           = $Node.PSDriveName
                PSDrivePath           = $Node.PSDrivePath
                DependsOn             = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($Package in $Node.Packages) {
            [string]$Name              = ""
            [string]$Path              = ""
            [string]$PackageSourcePath = ""

            $Package.GetEnumerator() | % {
                If ($_.key -eq "Name")              { $Name              = $_.value }
                If ($_.key -eq "Path")              { $Path              = "$($Node.PSDriveName):$($_.value)" }
                If ($_.key -eq "PackageSourcePath") { $PackageSourcePath = "$($Node.SourcePath)\$($_.value)" }
            }

            cMDTBuildPackage $Name.Replace(' ','') {
                Name              = $Name
                Path              = $Path
                PackageSourcePath = $PackageSourcePath
                PSDriveName       = $Node.PSDriveName
                PSDrivePath       = $Node.PSDrivePath
                DependsOn         = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($TaskSequence in $Node.TaskSequences) {
            [string]$Name     = ""
            [string]$Path     = ""
            [string]$OSName   = ""
            [string]$Template = ""
            [string]$ID       = ""
            [string]$OrgName  = ""

            $TaskSequence.GetEnumerator() | % {
                If ($_.key -eq "Name")     { $Name     = $_.value }
                If ($_.key -eq "Path")     { $Path     = "$($Node.PSDriveName):\Task Sequences\$($_.value)" }
                If ($_.key -eq "OSName")   { $OSName   = "$($Node.PSDriveName):\Operating Systems\$($_.value)" }
                If ($_.key -eq "Template") { $Template = $_.value }
                If ($_.key -eq "ID")       { $ID       = $_.value }
                If ($_.key -eq "OrgName")  { $OrgName  = $_.value }
            }

            # Create Task Sequence for one OS image
            cMDTBuildTaskSequence $Name.Replace(' ','') {
                Name        = $Name
                Path        = $Path
                OSName      = $OSName
                Template    = $Template
                ID          = $ID
                OrgName     = $OrgName
                PSDriveName = $Node.PSDriveName
                PSDrivePath = $Node.PSDrivePath
                DependsOn   = "[cMDTBuildDirectory]DeploymentFolder"
            }

            # Customize Task Sequence for one OS image
            ForEach ($TSCustomize in $TaskSequence.Customize) {
                [string]$Name             = ""
                [string]$NewName          = ""
                [string]$Type             = ""
                [string]$GroupName        = ""
                [string]$SubGroup         = ""
                [string]$Disable          = ""
                [string]$AddAfter         = ""
                [string]$Description      = ""
                [string]$TSVarName        = ""    # for MDT variable only
                [string]$TSVarValue       = ""    # for MDT variable only
                [string]$OSName           = ""    # for OS features only
                [string]$OSFeatures       = ""    # for OS features only
                [string]$Command          = ""    # for Run Command line only
                [string]$StartIn          = ""    # for Run Command line only
                [string]$PSCommand        = ""    # for Run PowerShell Script only
                [string]$PSParameters     = ""    # for Run PowerShell Script only
                [string]$SelectionProfile = ""    # for Install Updates Offline only

                $TSCustomize.GetEnumerator() | % {
                    If ($_.key -eq "Name")             { $Name             = $_.value }
                    If ($_.key -eq "NewName")          { $NewName          = $_.value }
                    If ($_.key -eq "Type")             { $Type             = $_.value }
                    If ($_.key -eq "GroupName")        { $GroupName        = $_.value }
                    If ($_.key -eq "SubGroup")         { $SubGroup         = $_.value }
                    If ($_.key -eq "Disable")          { $Disable          = $_.value }
                    If ($_.key -eq "AddAfter")         { $AddAfter         = $_.value }
                    if ($_.key -eq "Description")      { $Description      = $_.value }
                    if ($_.key -eq "TSVarName")        { $TSVarName        = $_.value }
                    if ($_.key -eq "TSVarValue")       { $TSVarValue       = $_.value }
                    If ($_.key -eq "OSName")           { $OSName           = $_.value }
                    If ($_.key -eq "OSFeatures")       { $OSFeatures       = $_.value }
                    If ($_.key -eq "Command")          { $Command          = $_.value }
                    If ($_.key -eq "StartIn")          { $StartIn          = $_.value }
                    If ($_.key -eq "PSCommand")        { $PSCommand        = $_.value }
                    If ($_.key -eq "PSParameters")     { $PSParameters     = $_.value }
                    If ($_.key -eq "SelectionProfile") { $SelectionProfile = $_.value }
                }

                # Current TS XML file name
                $TSFile = "$($Node.PSDrivePath)\Control\$($ID)\ts.xml"

                $CustomResource = $ID + '-' + $Name.Replace(' ','')
                cMDTBuildTaskSequenceCustomize $CustomResource {
                    TSFile           = $TSFile
                    Name             = $Name
                    NewName          = $NewName
                    Type             = $Type
                    GroupName        = $GroupName
                    SubGroup         = $SubGroup
                    Disable          = $Disable
                    AddAfter         = $AddAfter
                    Description      = $Description
                    TSVarName        = $TSVarName
                    TSVarValue       = $TSVarValue
                    OSName           = $OSName
                    OSFeatures       = $OSFeatures
                    Command          = $Command
                    StartIn          = $StartIn
                    PSCommand        = $PSCommand
                    PSParameters     = $PSParameters
                    SelectionProfile = $SelectionProfile
                    PSDriveName      = $Node.PSDriveName
                    PSDrivePath      = $Node.PSDrivePath
                }
            }
        }

        ForEach ($CustomSetting in $Node.CustomSettings) {
            [string]$Name        = ""
            [string]$SourcePath  = ""
            [string[]]$TestFiles = ""

            $CustomSetting.GetEnumerator() | % {
                If ($_.key -eq "Name")       { $Name       = $_.value }
                If ($_.key -eq "SourcePath") { $SourcePath = "$($Node.SourcePath)\$($_.value)" }
                If ($_.key -eq "TestFiles")  { $TestFiles  = $_.value }
            }

            cMDTBuildCustomize $Name.Replace(' ','') {
                Name         = $Name
                SourcePath   = $SourcePath
                TargetPath   = "Scripts"
                Path         = $Node.PSDrivePath
                TestFiles    = $TestFiles
                DependsOn    = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        ForEach ($IniFile in $Node.CustomizeIniFiles) {
            [string]$Name           = ""
            [string]$Path           = ""
            [string]$Company        = ""
            [string]$TimeZomeName   = ""
            [string]$WSUSServer     = ""
            [string]$UserLocale     = ""
            [string]$KeyboardLocale = ""

            $IniFile.GetEnumerator() | % {
                If ($_.key -eq "Name")           { $Name           = $_.value }
                If ($_.key -eq "Path")           { $Path           = "$($Node.PSDrivePath)$($_.value)" }
                If ($_.key -eq "Company")        { $Company        = $_.value }
                If ($_.key -eq "TimeZoneName")   { $TimeZoneName   = $_.value }
                If ($_.key -eq "WSUSServer")     { $WSUSServer     = $_.value }
                If ($_.key -eq "UserLocale")     { $UserLocale     = $_.value }
                If ($_.key -eq "KeyboardLocale") { $KeyboardLocale = $_.value }
            }

            If ($Company)        { $Company        = "_SMSTSORGNAME=$($Company)" }         Else { $Company        = ";_SMSTSORGNAME=" }
            If ($TimeZoneName)   { $TimeZoneName   = "TimeZoneName=$($TimeZoneName)" }     Else { $TimeZoneName   = ";TimeZoneName=" }
            If ($WSUSServer)     { $WSUSServer     = "WSUSServer=$($WSUSServer)" }         Else { $WSUSServer     = ";WSUSServer=" }
            If ($UserLocale)     { $UserLocale     = "UserLocale=$($UserLocale)" }         Else { $UserLocale     = ";UserLocale=" }
            If ($KeyboardLocale) { $KeyboardLocale = "KeyboardLocale=$($KeyboardLocale)" } Else { $KeyboardLocale = ";KeyboardLocale=" }

            If ($Name -eq "CustomSettingsIni") {
                cMDTBuildCustomSettingsIni ini {
                    Path      = $Path
                    DependsOn = "[cMDTBuildDirectory]DeploymentFolder"
                    Content   = @"
[Settings]
Priority=Serialnumber,Default
 
[Default]
$($Company)
OSInstall=Y
HideShell=YES
ApplyGPOPack=NO
UserDataLocation=NONE
DoNotCreateExtraPartition=YES
JoinWorkgroup=WORKGROUP
$($TimeZoneName)
$($WSUSServer)
;SLShare=%DeployRoot%\Logs
FinishAction=SHUTDOWN
 
;Set keyboard layout
$($UserLocale)
$($KeyboardLocale)
 
;Exclude updates that are already included in W7 Convenience update, but flagged incorrectly on Microsoft Update
WUMU_ExcludeKB1=2965788
WUMU_ExcludeKB2=2984976
WUMU_ExcludeKB3=3126446
WUMU_ExcludeKB4=3075222
WUMU_ExcludeKB5=3069762
WUMU_ExcludeKB6=3036493
WUMU_ExcludeKB7=3067904
WUMU_ExcludeKB8=3035017
WUMU_ExcludeKB9=3003743
WUMU_ExcludeKB10=3039976
WUMU_ExcludeKB11=2862330
WUMU_ExcludeKB12=2529073
 
ComputerBackupLocation=NETWORK
BackupShare=\\$($Node.NodeName)\$($Node.PSDriveShareName)
BackupDir=Captures
;BackupFile=#left("%TaskSequenceID%", len("%TaskSequenceID%")-3) & year(date) & right("0" & month(date), 2) & right("0" & day(date), 2)#.wim
;DoCapture=YES
 
;Disable all wizard pages
SkipAdminPassword=YES
SkipApplications=YES
SkipBitLocker=YES
SkipComputerBackup=YES
SkipComputerName=YES
SkipDomainMembership=YES
SkipFinalSummary=YES
SkipLocaleSelection=YES
SkipPackageDisplay=YES
SkipProductKey=YES
SkipRoles=YES
SkipSummary=YES
SkipTimeZone=YES
SkipUserData=YES
SkipTaskSequence=NO
SkipCapture=NO
"@

                }
            }

            If ($Name -eq "BootstrapIni") {
                cMDTBuildBootstrapIni ini {
                    Path      = $Path
                    DependsOn = "[cMDTBuildDirectory]DeploymentFolder"
                    Content   = @"
[Settings]
Priority=Default
 
[Default]
DeployRoot=\\$($Node.NodeName)\$($Node.PSDriveShareName)
SkipBDDWelcome=YES
 
;MDT Connect Account
UserID=$MDTUserName
UserPassword=$($Credentials.GetNetworkCredential().password)
UserDomain=$MDTUserDomain
"@

                }
            }
        }

        ForEach ($Image in $Node.BootImage) {
            [string]$Version                  = ""
            [string]$ExtraDirectory           = ""
            [string]$BackgroundFile           = ""
            [string]$LiteTouchWIMDescription  = ""

            $Image.GetEnumerator() | % {
                If ($_.key -eq "Version")                  { $Version                  = $_.value }
                If ($_.key -eq "ExtraDirectory")           { $ExtraDirectory           = $_.value }
                If ($_.key -eq "BackgroundFile")           { $BackgroundFile           = $_.value }
                If ($_.key -eq "LiteTouchWIMDescription")  { $LiteTouchWIMDescription  = $_.value }
            }

            cMDTBuildUpdateBootImage updateBootImage {
                Version                 = $Version
                PSDeploymentShare       = $Node.PSDriveName
                PSDrivePath             = $Node.PSDrivePath
                ExtraDirectory          = $ExtraDirectory
                BackgroundFile          = $BackgroundFile
                LiteTouchWIMDescription = $LiteTouchWIMDescription
                DependsOn               = "[cMDTBuildDirectory]DeploymentFolder"
            }
        }

        cNtfsPermissionEntry AssignPermissionsMDT {
            Ensure = "Present"
            Path   = $Node.PSDrivePath
            Principal  = "$MDTUserDomain\$MDTUserName"
            AccessControlInformation = @(
                cNtfsAccessControlInformation {
                    AccessControlType = "Allow"
                    FileSystemRights = "ReadAndExecute"
                    Inheritance = "ThisFolderSubfoldersAndFiles"
                    NoPropagateInherit = $false
                }
            )
            DependsOn  = "[cMDTBuildPersistentDrive]DeploymentPSDrive"
        }

        cNtfsPermissionEntry AssignPermissionsCaptures {
            Ensure = "Present"
            Path   = "$($Node.PSDrivePath)\Captures"
            Principal  = "$MDTUserDomain\$MDTUserName"
            AccessControlInformation = @(
                cNtfsAccessControlInformation {
                    AccessControlType = "Allow"
                    FileSystemRights = "Modify"
                    Inheritance = "ThisFolderSubfoldersAndFiles"
                    NoPropagateInherit = $false
                }
            )
            DependsOn  = "[cMDTBuildPersistentDrive]DeploymentPSDrive"
        }
    }
}

#Get password for MDT Account
$Cred = Get-Credential -UserName "SVCMDTConnect001" -Message "Enter password for MDT Account"
#$Cred = Get-Credential -UserName "Domain\User" -Message "Enter password for MDT Account"

#Get configuration data
[hashtable]$ConfigurationData = Get-ConfigurationData -ConfigurationData "$PSScriptRoot\Deploy_MDT_Server_ConfigurationData.psd1"
#[hashtable]$ConfigurationData = Get-ConfigurationData -ConfigurationData "$PSScriptRoot\Deploy_MDT_Server_ConfigurationData_Lite.psd1" # Only Windows 10 x86 Evaluation

#Create DSC MOF job
DeployMDTServerContract -OutputPath "$PSScriptRoot\MDT-Deploy_MDT_Server" -ConfigurationData $ConfigurationData -Credentials $Cred

#Set DSC LocalConfigurationManager
$winrmArgs = 'set winrm/config @{MaxEnvelopeSizekb="8192"}'
start-process "winrm" -ArgumentList $winrmArgs -NoNewWindow
Set-DscLocalConfigurationManager -Path "$PSScriptRoot\MDT-Deploy_MDT_Server" -Verbose

#Start DSC MOF job
Start-DscConfiguration -Wait -Force -Verbose -ComputerName "$env:computername" -Path "$PSScriptRoot\MDT-Deploy_MDT_Server"

#Set data deduplication
#Enable-DedupVolume -Volume "E:"
#Set-DedupVolume -Volume "E:" -MinimumFileAgeDays 1

Write-Output ""
Write-Output "Deploy MDT Server Builder completed!"