Overblog
Editer l'article Suivre ce blog Administration + Créer mon blog

Specialize cs.ini

Publié le par damcuvelier

param($cible)

$erroractionpreference = 'silentlycontinue'
Set-ExecutionPolicy bypass -force
$scriptpath = split-path -parent $MyInvocation.MyCommand.Path
$Country = $cible.replace("MEDIA","")
$Country = $cible.replace("UNC","")
$MDTCentral = "F:\DSLocal_France"
$ForceLPPath = "$MDTCentral\Applications\ForceLP"

$cible = "$scriptpath\$cible"
if($cible -match "MEDIA"){$cible = "$cible\Content\Deploy"}
if(!(test-path $cible)){cmd /c "md $cible"}
$csfile = "$cible\Control\CustomSettings.ini"
$bsfile = "$cible\Control\Bootstrap.ini"

Import-CSV -Path "$ForceLPPath\InfosLP.csv" -Delimiter ";" | foreach{
    # if(($_.Pays -match $Country) -and ($_.Site -match $Site)){
    if($_.Pays -match $Country){
    $langcode = $_.LocalLangCode
    $Keyboard = $_.LocalKeyb
    $DefLangCode = $_.DefLangCode
    $DefKeyb = $_.DefKeyb
    $TimeZone = $_.TimeZoneCode
    $TimeZoneName = $_.TimeZoneName
    $MDTSRV = $_.MDTSRV
    # $Site = $_.Site
    }
}
if(! (test-path "$ForceLPPath\Microsoft-Windows-Client-language-Pack_x64_$Langcode.cab")){$Langcode = $DefLangCode; $Keyboard = $DefKeyb}

(Get-Content $csfile) | ForEach {$_ -replace "LangCode=fr-FR","LangCode=$langcode"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "KeyboardLocale=040C:0000040C","KeyboardLocale=$Keyboard"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "COUNTRY=France","COUNTRY=$Country"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "TimeZone=105","TimeZone=$TimeZone"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "TimeZoneName=Romance Standard Time","TimeZoneName=$TimeZoneName"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "LangCode=%LangCode%","LangCode=$langcode"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "KeyboardLocale=%Keyboard%","KeyboardLocale=$Keyboard"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "COUNTRY=%COUNTRY%","COUNTRY=$Country"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "TimeZone=%TimeZone%","TimeZone=$TimeZone"} | Set-Content $csfile
(Get-Content $csfile) | ForEach {$_ -replace "TimeZoneName=%TimeZoneName%","TimeZoneName=$TimeZoneName"} | Set-Content $csfile

(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardInputLocalePE=040C:0000040C","KeyBoardInputLocalePE=$Keyboard"} | Set-Content $bsfile
(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardLocalePE=040C:0000040C","KeyBoardLocalePE=$Keyboard"} | Set-Content $bsfile
(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardLocale=040C:0000040C","KeyBoardLocale=$Keyboard"} | Set-Content $bsfile
(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardInputLocalePE=%Keyboard%","KeyBoardInputLocalePE=$Keyboard"} | Set-Content $bsfile
(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardLocalePE=%Keyboard%","KeyBoardLocalePE=$Keyboard"} | Set-Content $bsfile
(Get-Content $bsfile) | ForEach {$_ -replace "KeyBoardLocale=%Keyboard%","KeyBoardLocale=$Keyboard"} | Set-Content $bsfile


if($Keyboard -ne "040C:0000040C"){
$wim="$cible\Boot\LiteTouchPE_x64.wim"
$mount="$cible\Boot\LiteTouchPE"
cmd /c "md $mount"
cmd /c "Dism /Mount-Image /ImageFile:$wim /Index:1 /MountDir:$mount"
cmd /c "copy /Y $bsfile $mount\deploy\scripts\Bootstrap.ini"
cmd /c "Dism /Unmount-Image /MountDir:$mount /commit"
cmd /c "rmdir /S /Q $mount"
}


 

Commenter cet article