Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # ********************************** DEFINE VARIABLES ********************************
- $env:WorkDir = "D:\TEST"
- $installwim = "$env:WorkDir\Dvd\sources\install.wim"
- $slwim = "$env:WorkDir\Wim\sl.wim"
- $bootwim = "$env:WorkDir\Dvd\sources\boot.wim"
- $winrePro = "$env:WorkDir\Mount\pro\windows\system32\recovery\winre.wim"
- $winreHome = "$env:WorkDir\Mount\home\windows\system32\recovery\winre.wim"
- $winreSL = "$env:WorkDir\Mount\sl\windows\system32\recovery\winre.wim"
- $mntPro = "$env:WorkDir\Mount\pro"
- $mntHome = "$env:WorkDir\Mount\home"
- $mntSL = "$env:WorkDir\Mount\sl"
- $mntBoot = "$env:WorkDir\Mount\boot"
- $mntWinrePro = "$env:WorkDir\Mount\winrePro"
- $mntWinreHome = "$env:WorkDir\Mount\winreHome"
- $mntWinreSL = "$env:WorkDir\Mount\winreSL"
- $Updates = "$env:WorkDir\Updates"
- $Reg = "$env:WorkDir\Reg"
- $Temp = "$env:WorkDir\Temp"
- $LangEN = "$env:WorkDir\LangPack\en-us"
- $LangWinreEN = "$env:WorkDir\LangPack\winre\en-us"
- $LangBootEN = "$env:WorkDir\LangPack\boot\en-us"
- $winsxsPro = "$mntPro\Windows\WinSxs"
- $winsxsHome = "$mntHome\Windows\WinSxs"
- $winsxsSL= "$mntSL\Windows\WinSxs"
- $imagex = "$env:WorkDir\Tools\imagex_x64.exe"
- $SetACL = "$env:WorkDir\Tools\SetACL_x64.exe"
- $CastToDeviceREG = "HKLM:\WIM_Software\Classes\CLSID\{7AD84985-87B4-4a16-BE58-8B72A5B390F7}"
- $apps = @(
- "Microsoft.3DBuilder"
- "Microsoft.BingWeather"
- "Microsoft.DesktopAppInstaller"
- "Microsoft.Getstarted"
- "Microsoft.Messaging"
- "Microsoft.Microsoft3DViewer"
- "Microsoft.MicrosoftOfficeHub"
- "Microsoft.MicrosoftSolitaireCollection"
- #"Microsoft.MicrosoftStickyNotes"
- "Microsoft.MSPaint"
- "Microsoft.Office.OneNote"
- "Microsoft.OneConnect"
- "Microsoft.People"
- "Microsoft.SkypeApp"
- "Microsoft.StorePurchaseApp"
- "Microsoft.Wallet"
- #"Microsoft.Windows.Photos"
- "Microsoft.WindowsAlarms"
- "Microsoft.WindowsCalculator"
- #"Microsoft.WindowsCamera"
- "microsoft.windowscommunicationsapps"
- "Microsoft.WindowsFeedbackHub"
- "Microsoft.WindowsMaps"
- "Microsoft.WindowsSoundRecorder"
- #"Microsoft.WindowsStore"
- "Microsoft.XboxApp"
- "Microsoft.XboxGameOverlay"
- "Microsoft.XboxIdentityProvider"
- "Microsoft.XboxSpeechToTextOverlay"
- "Microsoft.ZuneMusic"
- "Microsoft.ZuneVideo"
- )
- $packages = @(
- "Microsoft-Windows-QuickAssist-Package~31bf3856ad364e35~amd64~~10.0.15063.0"
- "Microsoft-Windows-ContactSupport-Package~31bf3856ad364e35~amd64~~10.0.15063.0"
- #"Microsoft-Windows-MediaPlayer-Package~31bf3856ad364e35~amd64~~10.0.15063.0"
- )
- $featuresEnabling = @(
- #"DirectPlay"
- "NetFx3"
- )
- $featuresDisabling = @(
- "Microsoft-Windows-HyperV-Guest-Package"
- #"WindowsMediaPlayer"
- "FaxServicesClientPackage"
- )
- $mntWimPaths = @("$mntPro","$mntHome","$mntSL ")
- $mntWinRePaths = @("$mntWinrePro","$mntWinreHome","$mntWinreSL")
- $winsxsPaths = @("$winsxsPro","$winsxsHome","$winsxsSL")
- # ********************************** MENU ********************************
- Write-Host
- Write-Host "Press ENTER key to continue..."
- Read-Host
- CLS
- # ********************************** MOUNT IMAGES ********************************
- $host.ui.RawUI.WindowTitle = "Mounting install.wim Image"
- Mount-WindowsImage -ImagePath "$installwim" -Index 1 -Path "$mntPro"
- Mount-WindowsImage -ImagePath "$installwim" -Index 2 -Path "$mntHome"
- Mount-WindowsImage -ImagePath "$slwim" -Index 1 -Path "$mntSL"
- CLS
- $host.ui.RawUI.WindowTitle = "Mounting winre.wim Image"
- Mount-WindowsImage -ImagePath "$winrePro" -Index 1 -Path "$mntWinrePro"
- Mount-WindowsImage -ImagePath "$winreHome" -Index 1 -Path "$mntWinreHome"
- Mount-WindowsImage -ImagePath "$winreSL" -Index 1 -Path "$mntWinreSL"
- CLS
- $host.ui.RawUI.WindowTitle = "Mounting boot.wim Image"
- Mount-WindowsImage -ImagePath "$bootwim" -Index 2 -Path "$mntBoot"
- CLS
- # ********************************** REMOVE APPS AND PACKAGE ********************************
- $host.ui.RawUI.WindowTitle = "Removing Apps and Packages"
- Foreach ($mntPath in $mntWimPaths) {
- Foreach ($app in $apps) {
- Get-AppxProvisionedPackage -Path $mntPath | Where DisplayName -EQ $app | Remove-AppxProvisionedPackage
- Write-Host "Removed App : " $app " From " $mntPath -foregroundcolor "white" -backgroundcolor "red"
- Write-Host ""
- }
- }
- Foreach ($mntPath in $mntWimPaths) {
- Foreach ($package in $packages) {
- Get-WindowsPackage -Path $mntPath | Where PackageName -EQ $package | Remove-WindowsPackage
- Write-Host "Removed Package : " $package " From " $mntPath -foregroundcolor "white" -backgroundcolor "red"
- }
- }
- # ********************************** ENABLE - DISABLE FEATURES ********************************
- $host.ui.RawUI.WindowTitle = "Enable - Disable Features"
- Foreach ($mntPath in $mntWimPaths) {
- Foreach ($feature in $featuresEnabling) {
- Get-WindowsOptionalFeature -Path $mntPath | Where FeatureName -EQ $feature | Enable-WindowsOptionalFeature
- }
- }
- Foreach ($mntPath in $mntWimPaths) {
- Foreach ($feature in $featuresDisabling) {
- Get-WindowsOptionalFeature -Path $mntPath | Where FeatureName -EQ $feature | Disable-WindowsOptionalFeature
- }
- }
- # ********************************** INTEGRATE LANGUAGE PACK ********************************
- $host.ui.RawUI.WindowTitle = "Integrating Windows Language Pack"
- Foreach ($mntPath in $mntWimPaths) {
- Add-WindowsPackage -Path $mntPath -PackagePath $LangEN
- }
- DISM /Image:"$mntPro" /Gen-LangINI /Distribution:"$env:WorkDir\Dvd"
- CLS
- $host.ui.RawUI.WindowTitle = "Integrating Setup Language Pack"
- Add-WindowsPackage -Path "$mntBoot" -PackagePath "$LangBootEN"
- Copy-Item "$env:WorkDir\Dvd\sources\lang.ini" -Destination "$mntBoot\sources\lang.ini" -Force
- CLS
- $host.ui.RawUI.WindowTitle = "Integrating WinRe Language Pack"
- Foreach ($mntPath in $mntWinRePaths) {
- Add-WindowsPackage -Path $mntPath -PackagePath $LangWinreEN
- CLS
- }
- # ********************************** INTEGRATE UPDATES ********************************
- $host.ui.RawUI.WindowTitle = "Integrating Windows Updates"
- Foreach ($mntPath in $mntWimPaths) {
- Add-WindowsPackage -Path $mntPath -PackagePath "$Updates"
- CLS
- }
- # ********************************** IMPORT REGISTRY ********************************
- $host.ui.RawUI.WindowTitle = "Importing Registry Settings"
- Foreach ($mntPath in $mntWimPaths) {
- REG Load HKLM\WIM_Default $mntPath\Users\Default\NTUSER.DAT
- REG Load HKLM\WIM_Software $mntPath\Windows\System32\config\SOFTWARE
- REG Load HKLM\WIM_System $mntPath\Windows\System32\config\SYSTEM
- $SetACL -on $CastToDeviceREG -ot reg -actn setowner -ownr "n:Administrators" -rec yes
- $SetACL -on $CastToDeviceREG -ot reg -actn ace -ace "n:Administrators;p:full" -rec yes
- REG Import $Reg\System.reg
- REG Import $Reg\IE.reg
- REG Import $Reg\NavigationPane.reg
- REG Import $Reg\Photo.reg
- REG Import $Reg\Privacy.reg
- REG Import $Reg\ViewSetting.reg
- REG Import $Reg\Context.reg
- REG Unload HKLM\WIM_Default
- REG Unload HKLM\WIM_Software
- REG Unload HKLM\WIM_System
- }
- # ********************************** DISMOUNT IMAGES ********************************
- $host.ui.RawUI.WindowTitle = "DisMounting WinRe Image"
- Foreach ($mntPath in $mntWinRePaths) {
- Dismount-WindowsImage -Path $mntPath -Save
- }
- Export-WindowsImage -SIP "$winrePro" -SI 1 -DIP "$Temp\winre.wim" -DN "Microsoft Windows Recovery Environment (x64)" -CompressionType max
- Move-Item -Path "$Temp\winre.wim" -Destination "$mntPro\windows\system32\recovery" -Force
- Export-WindowsImage -SIP "$winreHome" -SI 1 -DIP "$Temp\winre.wim" -DN "Microsoft Windows Recovery Environment (x64)" -CompressionType max
- Move-Item -Path "$Temp\winre.wim" -Destination "$mntHome\windows\system32\recovery" -Force
- Export-WindowsImage -SIP "$winreSL" -SI 1 -DIP "$Temp\winre.wim" -DN "Microsoft Windows Recovery Environment (x64)" -CompressionType max
- Move-Item -Path "$Temp\winre.wim" -Destination "$mntSL\windows\system32\recovery" -Force
- CLS
- $host.ui.RawUI.WindowTitle = "DisMounting install.wim"
- Foreach ($mntPath in $mntWimPaths) {
- Dismount-WindowsImage -Path $mntPath -Save
- Write-Host "Dismounted Image : " $mntPath -foregroundcolor "white" -backgroundcolor "red"
- Write-Host ""
- }
- $host.ui.RawUI.WindowTitle = "DisMounting boot.wim"
- Dismount-WindowsImage -Path "$mntBoot" -Save
- CLS
- # ********************************** EXPORT IMAGES ********************************
- $host.ui.RawUI.WindowTitle = "Exporting Images"
- Export-WindowsImage -SIP "$installwim" -SI 1 -DIP "$Temp\install.wim" -DN "Windows 10 Pro" -CompressionType max
- Export-WindowsImage -SIP "$installwim" -SI 2 -DIP "$Temp\install.wim" -DN "Windows 10 Home" -CompressionType max
- Export-WindowsImage -SIP "$slwim" -SI 1 -DIP "$Temp\install.wim" -DN "Windows 10 Home Single Language" -CompressionType max
- Export-WindowsImage -SIP "$bootwim" -SI 1 -DIP "$Temp\boot.wim" -DN "Microsoft Windows PE (x64)" -CompressionType max
- Export-WindowsImage -SIP "$bootwim" -SI 2 -DIP "$Temp\boot.wim" -DN "Microsoft Windows Setup (x64)" -CompressionType max
- Move-Item -Path "$Temp\*" -Destination "$env:WorkDir\Dvd\sources" -Force
- # ********************************** MAKE ISO ********************************
- Start-Process cmd.exe "/c $env:WorkDir\makeiso.bat"
- EXIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement