<#
.Synopsis
    Script for Windows 10 Deployment
.DESCRIPTION
    Script for Windows 10 Deployment
.EXAMPLE
    C:\Setup\Scripts\Set-SCCMBootLangage.ps1 -Architecture amd64 -Langage fr-fr
.NOTES
    Created:	 2016-02-1
    Version:	 1.0

    Author - Jérôme Bezet-Torres
    Twitter: @JM2K69
    
    Disclaimer:
    This script is provided "AS IS" with no warranties, confers no rights and 
    is not supported by the authors or Deployment Artist.
#>

[cmdletbinding(SupportsShouldProcess=$True)]
Param
(
    [parameter(mandatory=$True,ValueFromPipelineByPropertyName=$true,Position=0)]
    [ValidateNotNullOrEmpty()]
    [ValidateSet("x86","amd64")]
    $Architecture,
	[ValidateSet('fr-fr', 'es-es', 'it-it', 'de-de')]
    $Langage
)

# 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..."
    Throw
}

#region variables

$ADK_Path = "C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit"
$WinPE_ADK_Path = $ADK_Path + "\Windows Preinstallation Environment"
$WinPE_OCs_Path = $WinPE_ADK_Path + "\$Architecture\WinPE_OCs"
$DISM_Path = $ADK_Path + "\Deployment Tools" + "\$Architecture\DISM"
$DISM_Path2 = $ADK_Path +"\Deployment Tools" +"\$Architecture\Oscdimg"
$ADK_Path_Media =$ADK_Path + $WinPE_ADK_Path + "\$Architecture\Media"
$ADK_Deploy = $ADK_Path + "\Deployment Tools"


#endregion

switch ($Architecture)
{
    x86
    {
        $WinPE_BuildFolder = "E:\Program Files\Microsoft Configuration Manager\OSD\boot\i386"
        $WinPE_MountFolder = "E:\Program Files\Microsoft Configuration Manager\OSD\boot\i386\Mount"

    }
    amd64
    {
        $WinPE_BuildFolder = "E:\Program Files\Microsoft Configuration Manager\OSD\boot\x64"
        $WinPE_MountFolder = "E:\Program Files\Microsoft Configuration Manager\OSD\boot\x64\Mount"

    }
        
        
    }

    if (!(Test-Path -path $WinPE_MountFolder)) {New-Item $WinPE_MountFolder -Type Directory| Out-Null}
$WimFile = "$WinPE_BuildFolder\boot.wim"
Mount-WindowsImage -ImagePath $WimFile -Path $WinPE_MountFolder -Index 1;

write-host "#################################################################" -ForegroundColor yellow
Write-Host "             New WinPe Default Langage is set to $Langage                        "-ForegroundColor Yellow
write-host "#################################################################"-ForegroundColor Yellow 

& $DISM_Path\dism.exe /Image:$WinPE_MountFolder /Add-Package /PackagePath:$WinPE_OCs_Path\$Langage\lp.cab
& $DISM_Path\dism.exe /Set-AllIntl:$Langage /Image:$WinPE_MountFolder

Dismount-WindowsImage -Path $WinPE_MountFolder -Save
Start-Sleep 3 
Export-WindowsImage -SourceImagePath "$WinPE_BuildFolder\boot.wim" -SourceIndex 1 -DestinationImagePath "$WinPE_BuildFolder\boot2.wim"
Remove-Item "$WinPE_BuildFolder\boot.wim"
Rename-Item -Path "$WinPE_BuildFolder\boot2.wim" -NewName "$WinPE_BuildFolder\boot.wim"

