mirror of
https://github.com/rbalsleyMSFT/FFU.git
synced 2026-06-14 02:09:35 -06:00
@@ -5,9 +5,12 @@ REM d:\Office\setup.exe /configure d:\office\DeployFFU.xml
|
|||||||
REM Install Defender Platform Update
|
REM Install Defender Platform Update
|
||||||
REM Install Defender Definitions
|
REM Install Defender Definitions
|
||||||
REM Install Windows Security Platform Update
|
REM Install Windows Security Platform Update
|
||||||
|
REM Install Windows Malicious Software Removal Tool
|
||||||
REM Install OneDrive Per Machine
|
REM Install OneDrive Per Machine
|
||||||
REM Install Edge Stable
|
REM Install Edge Stable
|
||||||
REM Winget Win32 Apps
|
REM Winget Win32 Apps
|
||||||
|
REM START Batch variables placeholder
|
||||||
|
REM END Batch variables placeholder
|
||||||
REM Add additional apps below here
|
REM Add additional apps below here
|
||||||
REM Contoso App (Example)
|
REM Contoso App (Example)
|
||||||
REM msiexec /i d:\Contoso\setup.msi /qn /norestart
|
REM msiexec /i d:\Contoso\setup.msi /qn /norestart
|
||||||
|
|||||||
+1048
-508
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -4,22 +4,34 @@ param(
|
|||||||
$DeployISOPath,
|
$DeployISOPath,
|
||||||
[Switch]$DisableAutoPlay
|
[Switch]$DisableAutoPlay
|
||||||
)
|
)
|
||||||
$Host.UI.RawUI.WindowTitle = 'USB Imaging Tool Creator'
|
$Host.UI.RawUI.WindowTitle = 'Imaging Tool USB Creator'
|
||||||
|
|
||||||
if($DeployISOPath){
|
if($DeployISOPath){
|
||||||
$DevelopmentPath = $DeployISOPath | Split-Path
|
$DevelopmentPath = $DeployISOPath | Split-Path
|
||||||
|
$ImagesPath = "$DevelopmentPath\FFU"
|
||||||
function WriteLog($LogText) {
|
function WriteLog($LogText) {
|
||||||
$LogFileName = '\Script.log'
|
$LogFileName = '\Script.log'
|
||||||
$LogFile = $DevelopmentPath + $LogFilename
|
$LogFile = $DevelopmentPath + $LogFilename
|
||||||
Add-Content -path $LogFile -value "$((Get-Date).ToString()) $LogText" -Force -ErrorAction SilentlyContinue
|
Add-Content -path $LogFile -value "$((Get-Date).ToString()) $LogText" -Force -ErrorAction SilentlyContinue
|
||||||
Write-Verbose $LogText
|
Write-Verbose $LogText
|
||||||
}
|
}
|
||||||
Function Get-USBDrive {
|
|
||||||
$USBDrives = (Get-WmiObject -Class Win32_DiskDrive -Filter "MediaType='Removable Media'")
|
function Write-ProgressLog {
|
||||||
If ($USBDrives -and ($null -eq $USBDrives.count)) {
|
param(
|
||||||
$USBDrivesCount = 1
|
[string]$Activity,
|
||||||
|
[string]$Status
|
||||||
|
)
|
||||||
|
Write-Progress -Activity $Activity -Status $Status -PercentComplete (($currentStep / $totalSteps) * 100)
|
||||||
|
WriteLog $Status
|
||||||
|
$script:currentStep++
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
Function Get-RemovableDrive {
|
||||||
|
writelog "Get information for all removable drives"
|
||||||
|
$USBDrives = Get-WmiObject Win32_DiskDrive | Where-Object {$_.MediaType -eq "Removable media"}
|
||||||
|
If($USBDrives -and ($null -eq $USBDrives.count)) {
|
||||||
|
$USBDrivesCount = 1
|
||||||
|
} else {
|
||||||
$USBDrivesCount = $USBDrives.Count
|
$USBDrivesCount = $USBDrives.Count
|
||||||
}
|
}
|
||||||
WriteLog "Found $USBDrivesCount USB drives"
|
WriteLog "Found $USBDrivesCount USB drives"
|
||||||
@@ -27,20 +39,23 @@ Function Get-USBDrive {
|
|||||||
if ($null -eq $USBDrives) {
|
if ($null -eq $USBDrives) {
|
||||||
WriteLog "No removable USB drive found. Exiting"
|
WriteLog "No removable USB drive found. Exiting"
|
||||||
Write-Error "No removable USB drive found. Exiting"
|
Write-Error "No removable USB drive found. Exiting"
|
||||||
|
Pause
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
return $USBDrives, $USBDrivesCount
|
return $USBDrives, $USBDrivesCount
|
||||||
}
|
}
|
||||||
|
|
||||||
Function Build-DeploymentUSB{
|
Function Build-DeploymentUSB{
|
||||||
param(
|
param(
|
||||||
[Array]$Drives
|
[Array]$Drives
|
||||||
)
|
)
|
||||||
writelog "Checking if ffu files are present in the ffu folder"
|
writelog "Creating list of FFU image files"
|
||||||
$Images = Get-ChildItem -Path $FFUPath -Filter "*.ffu" -File -Recurse
|
$Images = Get-ChildItem -Path $ImagesPath -Filter "*.ffu" -File -Recurse
|
||||||
writelog "Checking if drivers are present in the drivers folder"
|
writelog "Checking if drivers are present in the drivers folder"
|
||||||
$Drivers = Get-ChildItem -Path $DriversPath -Recurse
|
$Drivers = Get-ChildItem -Path $DriversPath -Recurse
|
||||||
$DrivesCount = $Drives.Count
|
$DrivesCount = $Drives.Count
|
||||||
Writelog "Creating partitions..."
|
Write-ProgressLog "Create Imaging Tool" "Creating partitions..."
|
||||||
|
writelog "Create job to partition each usb drive"
|
||||||
foreach ($USBDrive in $Drives) {
|
foreach ($USBDrive in $Drives) {
|
||||||
$DriveNumber = $USBDrive.DeviceID.Replace("\\.\PHYSICALDRIVE", "")
|
$DriveNumber = $USBDrive.DeviceID.Replace("\\.\PHYSICALDRIVE", "")
|
||||||
$Model = $USBDrive.model
|
$Model = $USBDrive.model
|
||||||
@@ -65,7 +80,7 @@ Function Build-DeploymentUSB{
|
|||||||
if($DrivesCount -gt 1){
|
if($DrivesCount -gt 1){
|
||||||
writelog "Get file system information for all drives"
|
writelog "Get file system information for all drives"
|
||||||
$Partitions = Get-Partition | Get-Volume
|
$Partitions = Get-Partition | Get-Volume
|
||||||
}else{
|
} else {
|
||||||
writelog "Get file system information for drive number $DiskNumber"
|
writelog "Get file system information for drive number $DiskNumber"
|
||||||
$Partitions = Get-Partition -DiskNumber $DriveNumber | Get-Volume
|
$Partitions = Get-Partition -DiskNumber $DriveNumber | Get-Volume
|
||||||
}
|
}
|
||||||
@@ -97,11 +112,19 @@ $Destination = $Drive + ":\"
|
|||||||
[string]$SFolder,
|
[string]$SFolder,
|
||||||
[string]$DFolder
|
[string]$DFolder
|
||||||
)
|
)
|
||||||
|
New-Item -Path $DFolder -ItemType Directory -Force -Confirm: $false | Out-Null
|
||||||
Robocopy $SFolder $DFolder /E /COPYALL /R:5 /W:5 /J
|
Robocopy $SFolder $DFolder /E /COPYALL /R:5 /W:5 /J
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteLog "Start job to copy all FFU files to $Destination"
|
WriteLog "Start job to copy all FFU files to $Destination"
|
||||||
Start-Job -ScriptBlock $jobScriptBlock -ArgumentList $FFUPath, $Destination | Out-Null
|
Start-Job -ScriptBlock $jobScriptBlock -ArgumentList $ImagesPath, $Destination | Out-Null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!($Images)){
|
||||||
|
foreach ($Drive in $DeployDrives) {
|
||||||
|
WriteLog "Create images directory"
|
||||||
|
$drivepath = $Drive + ":\"
|
||||||
|
New-Item -Path "$drivepath" -Name Images -ItemType Directory -Force -Confirm: $false | Out-Null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($Drivers){
|
if($Drivers){
|
||||||
@@ -128,14 +151,14 @@ if(!($Drivers)){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($DrivesCount -gt 1){
|
if($DrivesCount -gt 1){
|
||||||
Writelog "Building $DrivesCount drives concurrently...Please be patient..."
|
Write-ProgressLog "Create Imaging Tool" "Building $DrivesCount drives concurrently...Please be patient..."
|
||||||
}else{
|
} else {
|
||||||
Writelog "Building the imaging tool on $model...Please be patient..."
|
Write-ProgressLog "Create Imaging Tool" "Building the imaging tool on $model...Please be patient..."
|
||||||
}
|
}
|
||||||
Get-Job | Wait-Job | Out-Null
|
Get-Job | Wait-Job | Out-Null
|
||||||
|
|
||||||
Dismount-DiskImage -ImagePath $DeployISOPath | Out-Null
|
Dismount-DiskImage -ImagePath $DeployISOPath | Out-Null
|
||||||
Writelog "Drive creation jobs completed..."
|
Write-ProgressLog "Create Imaging Tool" "Drive creation jobs completed..."
|
||||||
}
|
}
|
||||||
|
|
||||||
Function New-DeploymentUSB {
|
Function New-DeploymentUSB {
|
||||||
@@ -167,20 +190,15 @@ Function New-DeploymentUSB {
|
|||||||
$var = $true
|
$var = $true
|
||||||
$DriveSelected = Read-Host 'Enter the drive number to apply the .iso to'
|
$DriveSelected = Read-Host 'Enter the drive number to apply the .iso to'
|
||||||
$DriveSelected = ($DriveSelected -as [int]) -1
|
$DriveSelected = ($DriveSelected -as [int]) -1
|
||||||
if($Last){
|
writelog "Drive $DriveSelected selected"
|
||||||
writelog "All drives selected"
|
|
||||||
}else{
|
|
||||||
writelog "Drive $DriveSelected selected"}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
catch {
|
catch {
|
||||||
Write-Host 'Input was not in correct format. Please enter a valid FFU number'
|
Write-Host 'Input was not in correct format. Please enter a valid FFU number'
|
||||||
$var = $false
|
$var = $false
|
||||||
}
|
}
|
||||||
} until (($DriveSelected -le $Count -1 -or $last) -and $var)
|
} until (($DriveSelected -le $Count -1 -or $last) -and $var)
|
||||||
|
if($DisableAutoPlay){
|
||||||
$DisableAutoPlayCurrentSetting = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name DisableAutoplay).DisableAutoplay
|
|
||||||
if($DisableAutoPlay -and $DisableAutoPlayCurrentSetting -ne 1){
|
|
||||||
writelog "Disable autoPlay current setting is $DisableAutoPlayCurrentSetting"
|
|
||||||
WriteLog "Setting the registry key to disable autoplay for all drives"
|
WriteLog "Setting the registry key to disable autoplay for all drives"
|
||||||
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 1 -Type DWORD
|
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 1 -Type DWORD
|
||||||
}
|
}
|
||||||
@@ -193,16 +211,16 @@ Function New-DeploymentUSB {
|
|||||||
if($Selection -eq $last){
|
if($Selection -eq $last){
|
||||||
Read-Host -Prompt "ALL DRIVES SELECTED! WILL ERASE ALL CURRENTLY CONNECTED USB DRIVES!! Press ENTER to continue"
|
Read-Host -Prompt "ALL DRIVES SELECTED! WILL ERASE ALL CURRENTLY CONNECTED USB DRIVES!! Press ENTER to continue"
|
||||||
Build-DeploymentUSB -Drives $Drives
|
Build-DeploymentUSB -Drives $Drives
|
||||||
}else{
|
} else {
|
||||||
Read-Host -Prompt "Drive number $Selection was selected. Press ENTER to continue"
|
Read-Host -Prompt "Drive number $Selection was selected. Press ENTER to continue"
|
||||||
Build-DeploymentUSB -Drives $Drives[$DriveSelected]
|
Build-DeploymentUSB -Drives $Drives[$DriveSelected]
|
||||||
}
|
}
|
||||||
WriteLog "Setting the registry key to re-enable autoplay for all drives"
|
WriteLog "Setting the registry key to re-enable autoplay for all drives"
|
||||||
if($DisableAutoPlay){
|
if($DisableAutoPlay){
|
||||||
Writelog "Setting disable autoplay setting back to $DisableAutoPlayCurrentSetting"
|
Write-ProgressLog "Create Imaging Tool" "Enabling Autoplay"
|
||||||
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value $DisableAutoPlayCurrentSetting -Type DWORD
|
Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\AutoplayHandlers" -Name "DisableAutoplay" -Value 0 -Type DWORD
|
||||||
}
|
}
|
||||||
Writelog "Completed!"
|
Write-ProgressLog "Create Imaging Tool" "Completed!"
|
||||||
}
|
}
|
||||||
#Get USB Drive and create log file
|
#Get USB Drive and create log file
|
||||||
if(Test-Path "$DevelopmentPath\Script.log"){
|
if(Test-Path "$DevelopmentPath\Script.log"){
|
||||||
@@ -211,12 +229,15 @@ New-item -Path $DevelopmentPath -Name 'Script.log' -ItemType "file" -Force | Out
|
|||||||
}
|
}
|
||||||
WriteLog 'Begin Logging'
|
WriteLog 'Begin Logging'
|
||||||
WriteLog 'Getting USB drive information and usb drive count'
|
WriteLog 'Getting USB drive information and usb drive count'
|
||||||
$USBDrives,$USBDrivesCount = Get-USBDrive
|
$USBDrives,$USBDrivesCount = Get-RemovableDrive
|
||||||
|
WriteLog 'Setting first step for percentage progress bar'
|
||||||
|
$currentStep = 1
|
||||||
New-DeploymentUSB -Drives $USBDrives -Count $USBDrivesCount
|
New-DeploymentUSB -Drives $USBDrives -Count $USBDrivesCount
|
||||||
|
|
||||||
read-host -Prompt "USB drive creation complete. Press ENTER to exit"
|
read-host -Prompt "USB drive creation complete. Press ENTER to exit"
|
||||||
|
|
||||||
Exit
|
Exit
|
||||||
}else{
|
} else {
|
||||||
Write-Host "No .ISO file selected..."
|
Write-Host "No .ISO file selected..."
|
||||||
read-host "Press ENTER to Exit..."
|
read-host "Press ENTER to Exit..."
|
||||||
Exit
|
Exit
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#Modify the net use W: \\192.168.1.158\FFUCaptureShare /user:ffu_user ddb1f077-3eed-433c-b4d9-7b8cd54ce727
|
#Modify the net use W: \\192.168.1.158\FFUCaptureShare /user:ffu_user ddb1f077-3eed-433c-b4d9-7b8cd54ce727
|
||||||
net use W: \\192.168.1.158\FFUCaptureShare /user:ffu_user ddb1f077-3eed-433c-b4d9-7b8cd54ce727
|
net use W: \\192.168.1.158\FFUCaptureShare /user:ffu_user ddb1f077-3eed-433c-b4d9-7b8cd54ce727
|
||||||
|
#Custom naming placeholder
|
||||||
|
|
||||||
$AssignDriveLetter = 'x:\AssignDriveLetter.txt'
|
$AssignDriveLetter = 'x:\AssignDriveLetter.txt'
|
||||||
Start-Process -FilePath diskpart.exe -ArgumentList "/S $AssignDriveLetter" -Wait -ErrorAction Stop | Out-Null
|
Start-Process -FilePath diskpart.exe -ArgumentList "/S $AssignDriveLetter" -Wait -ErrorAction Stop | Out-Null
|
||||||
@@ -11,53 +12,89 @@ reg load "HKLM\FFU" $Software
|
|||||||
|
|
||||||
$SKU = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'EditionID'
|
$SKU = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'EditionID'
|
||||||
[int]$CurrentBuild = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'CurrentBuild'
|
[int]$CurrentBuild = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'CurrentBuild'
|
||||||
$DisplayVersion = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'DisplayVersion'
|
if ($CurrentBuild -notin 14393, 17763) {
|
||||||
|
$WindowsVersion = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'DisplayVersion'
|
||||||
|
}
|
||||||
|
$InstallationType = Get-ItemPropertyValue -Path 'HKLM:\FFU\Microsoft\Windows NT\CurrentVersion\' -Name 'InstallationType'
|
||||||
$BuildDate = Get-Date -uformat %b%Y
|
$BuildDate = Get-Date -uformat %b%Y
|
||||||
|
|
||||||
$SKU = switch ($SKU) {
|
$SKU = switch ($SKU) {
|
||||||
Core { 'Home' }
|
Core { 'Home' }
|
||||||
CoreN { 'HomeN'}
|
CoreN { 'HomeN' }
|
||||||
CoreSingleLanguage { 'HomeSL'}
|
CoreSingleLanguage { 'HomeSL' }
|
||||||
Professional { 'Pro' }
|
Professional { 'Pro' }
|
||||||
ProfessionalN { 'ProN'}
|
ProfessionalN { 'ProN' }
|
||||||
ProfessionalEducation { 'Pro_Edu' }
|
ProfessionalEducation { 'Pro_Edu' }
|
||||||
ProfessionalEducationN { 'Pro_EduN' }
|
ProfessionalEducationN { 'Pro_EduN' }
|
||||||
Enterprise { 'Ent' }
|
Enterprise { 'Ent' }
|
||||||
EnterpriseN { 'EntN'}
|
EnterpriseN { 'EntN' }
|
||||||
Education { 'Edu' }
|
Education { 'Edu' }
|
||||||
EducationN { 'EduN'}
|
EducationN { 'EduN' }
|
||||||
ProfessionalWorkstation { 'Pro_Wks' }
|
ProfessionalWorkstation { 'Pro_Wks' }
|
||||||
ProfessionalWorkstationN { 'Pro_WksN' }
|
ProfessionalWorkstationN { 'Pro_WksN' }
|
||||||
|
ServerStandard { 'Srv_Std' }
|
||||||
|
ServerDatacenter { 'Srv_Dtc' }
|
||||||
}
|
}
|
||||||
|
|
||||||
if($CurrentBuild -ge 22000){
|
if ($InstallationType -eq "Client") {
|
||||||
$Name = 'Win11'
|
if ($CurrentBuild -ge 22000) {
|
||||||
|
$WindowsRelease = 'Win11'
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$WindowsRelease = 'Win10'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
$Name = 'Win10'
|
$WindowsRelease = switch ($CurrentBuild) {
|
||||||
|
26100 { '2025' }
|
||||||
|
20348 { '2022' }
|
||||||
|
17763 { '2019' }
|
||||||
|
14393 { '2016' }
|
||||||
|
Default { $WindowsVersion }
|
||||||
|
}
|
||||||
|
if ($InstallationType -eq "Server Core") {
|
||||||
|
$SKU += "_Core"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#If Office is installed, modify the file name of the FFU
|
if ($CustomFFUNameTemplate) {
|
||||||
#$Office = Get-childitem -Path 'M:\Program Files\Microsoft Office' -ErrorAction SilentlyContinue | Out-Null
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{WindowsRelease}', $WindowsRelease
|
||||||
$Office = Get-childitem -Path 'M:\Program Files\Microsoft Office' -ErrorAction SilentlyContinue
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{WindowsVersion}', $WindowsVersion
|
||||||
if($Office){
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{SKU}', $SKU
|
||||||
$ffuFilePath = "W:\$Name`_$DisplayVersion`_$SKU`_Office`_$BuildDate.ffu"
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{BuildDate}', $BuildDate
|
||||||
$dismArgs = "/capture-ffu /imagefile=$ffuFilePath /capturedrive=\\.\PhysicalDrive0 /name:$Name$DisplayVersion$SKU /Compress:Default"
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{yyyy}', (Get-Date -UFormat '%Y')
|
||||||
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -creplace '{MM}', (Get-Date -UFormat '%m')
|
||||||
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{dd}', (Get-Date -UFormat '%d')
|
||||||
}
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -creplace '{HH}', (Get-Date -UFormat '%H')
|
||||||
else{
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -creplace '{hh}', (Get-Date -UFormat '%I')
|
||||||
$ffuFilePath = "W:\$Name`_$DisplayVersion`_$SKU`_Apps`_$BuildDate.ffu"
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -creplace '{mm}', (Get-Date -UFormat '%M')
|
||||||
$dismArgs = "/capture-ffu /imagefile=$ffuFilePath /capturedrive=\\.\PhysicalDrive0 /name:$Name$DisplayVersion$SKU /Compress:Default"
|
$CustomFFUNameTemplate = $CustomFFUNameTemplate -replace '{tt}', (Get-Date -UFormat '%p')
|
||||||
|
if($CustomFFUNameTemplate -notlike '*.ffu') {
|
||||||
|
$CustomFFUNameTemplate += '.ffu'
|
||||||
|
}
|
||||||
|
$dismArgs = "/capture-ffu /imagefile=W:\$CustomFFUNameTemplate /capturedrive=\\.\PhysicalDrive0 /name:$WindowsRelease$WindowsVersion$SKU /Compress:Default"
|
||||||
|
} else {
|
||||||
|
#If Office is installed, modify the file name of the FFU
|
||||||
|
#$Office = Get-childitem -Path 'M:\Program Files\Microsoft Office' -ErrorAction SilentlyContinue | Out-Null
|
||||||
|
$Office = Get-ChildItem -Path 'M:\Program Files\Microsoft Office' -ErrorAction SilentlyContinue
|
||||||
|
if ($Office) {
|
||||||
|
$ffuFilePath = "W:\$WindowsRelease`_$WindowsVersion`_$SKU`_Office`_$BuildDate.ffu"
|
||||||
|
} else {
|
||||||
|
$ffuFilePath = "W:\$WindowsRelease`_$WindowsVersion`_$SKU`_Apps`_$BuildDate.ffu"
|
||||||
|
}
|
||||||
|
$dismArgs = "/capture-ffu /imagefile=$ffuFilePath /capturedrive=\\.\PhysicalDrive0 /name:$WindowsRelease$WindowsVersion$SKU /Compress:Default"
|
||||||
}
|
}
|
||||||
|
|
||||||
#Unload Registry
|
#Unload Registry
|
||||||
Set-Location X:\
|
Set-Location X:\
|
||||||
Remove-Variable SKU
|
Remove-Variable SKU
|
||||||
Remove-Variable CurrentBuild
|
Remove-Variable CurrentBuild
|
||||||
Remove-Variable DisplayVersion
|
if ($CurrentBuild -notin 14393, 17763) {
|
||||||
Remove-Variable Office
|
Remove-Variable WindowsVersion
|
||||||
|
}
|
||||||
|
if($Office) {
|
||||||
|
Remove-Variable Office
|
||||||
|
}
|
||||||
reg unload "HKLM\FFU"
|
reg unload "HKLM\FFU"
|
||||||
#This prevents Critical Process Died errors you can have during deployment of the FFU - may not happen during capture from WinPE, but adding here to be consistent with VHDX capture
|
#This prevents Critical Process Died errors you can have during deployment of the FFU - may not happen during capture from WinPE, but adding here to be consistent with VHDX capture
|
||||||
Write-Host "Sleeping for 60 seconds to allow registry to unload prior to capture"
|
Write-Host "Sleeping for 60 seconds to allow registry to unload prior to capture"
|
||||||
@@ -65,5 +102,4 @@ Start-sleep 60
|
|||||||
Start-Process -FilePath dism.exe -ArgumentList $dismArgs -Wait -PassThru -ErrorAction Stop | Out-Null
|
Start-Process -FilePath dism.exe -ArgumentList $dismArgs -Wait -PassThru -ErrorAction Stop | Out-Null
|
||||||
#Copy DISM log to Host
|
#Copy DISM log to Host
|
||||||
xcopy X:\Windows\logs\dism\dism.log W:\ /Y | Out-Null
|
xcopy X:\Windows\logs\dism\dism.log W:\ /Y | Out-Null
|
||||||
|
|
||||||
wpeutil Shutdown
|
wpeutil Shutdown
|
||||||
|
|||||||
@@ -55,11 +55,18 @@ function Set-DiskpartAnswerFiles($DiskpartFile,$DiskID){
|
|||||||
|
|
||||||
function Set-Computername($computername){
|
function Set-Computername($computername){
|
||||||
[xml]$xml = Get-Content $UnattendFile
|
[xml]$xml = Get-Content $UnattendFile
|
||||||
if($xml.unattend.settings.component.Count -ge 2){
|
$components = $xml.unattend.settings.component
|
||||||
#Assumes that Computername is the first component element
|
$found = $false
|
||||||
$xml.unattend.settings.component[0].ComputerName = $computername
|
foreach ($component in $components) {
|
||||||
}else{
|
if ($component.ComputerName) {
|
||||||
$xml.unattend.settings.component.ComputerName = $computername
|
$component.ComputerName = $computername
|
||||||
|
$found = $true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (-not $found) {
|
||||||
|
WriteLog 'ComputerName element not found in unattend.xml.'
|
||||||
|
throw 'ComputerName element not found in unattend.xml.'
|
||||||
}
|
}
|
||||||
$xml.Save($UnattendFile)
|
$xml.Save($UnattendFile)
|
||||||
return $computername
|
return $computername
|
||||||
@@ -128,14 +135,14 @@ $LogFileName = 'ScriptLog.txt'
|
|||||||
$USBDrive = Get-USBDrive
|
$USBDrive = Get-USBDrive
|
||||||
New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null
|
New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null
|
||||||
$LogFile = $USBDrive + $LogFilename
|
$LogFile = $USBDrive + $LogFilename
|
||||||
$version = '2409.1'
|
$version = '2412.1'
|
||||||
WriteLog 'Begin Logging'
|
WriteLog 'Begin Logging'
|
||||||
WriteLog "Script version: $version"
|
WriteLog "Script version: $version"
|
||||||
|
|
||||||
#Find PhysicalDrive
|
#Find PhysicalDrive
|
||||||
# $PhysicalDeviceID = Get-HardDrive
|
# $PhysicalDeviceID = Get-HardDrive
|
||||||
$hardDrive = Get-HardDrive
|
$hardDrive = Get-HardDrive
|
||||||
if($hardDrive -eq $null){
|
if($null -eq $hardDrive){
|
||||||
WriteLog 'No hard drive found. Exiting'
|
WriteLog 'No hard drive found. Exiting'
|
||||||
WriteLog 'Try adding storage drivers to the PE boot image (you can re-create your FFU and USB drive and add the PE drivers to the PEDrivers folder and add -CopyPEDrivers $true to the command line, or manually add them via DISM)'
|
WriteLog 'Try adding storage drivers to the PE boot image (you can re-create your FFU and USB drive and add the PE drivers to the PEDrivers folder and add -CopyPEDrivers $true to the command line, or manually add them via DISM)'
|
||||||
Exit
|
Exit
|
||||||
|
|||||||
Binary file not shown.
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<unattend xmlns="urn:schemas-microsoft-com:unattend" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State">
|
||||||
|
<settings pass="specialize">
|
||||||
|
<!--<ComputerName> must be in the first Component Element "Microsoft-Windows-Shell-Setup" . Do not change the order or remove it -->
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<ComputerName>MYCOMPUTER</ComputerName><!--Leave Default will be renamed-->
|
||||||
|
<TimeZone>Eastern Standard Time</TimeZone><!--Add Your Local TimeZone-->
|
||||||
|
</component>
|
||||||
|
<!-- Place additional Components Elements and Settings below here: -->
|
||||||
|
<component name="Microsoft-Windows-Deployment" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
|
<RunASynchronous>
|
||||||
|
<RunASynchronousCommand wcm:action="add">
|
||||||
|
<Order>1</Order>
|
||||||
|
<Path>cmd.exe /c date 09-07-2024</Path> <!--Set the device clock to the current date. Helpful when BIOS clocks out of sync. -->
|
||||||
|
<Description>Set system date to a specific date</Description>
|
||||||
|
</RunASynchronousCommand>
|
||||||
|
</RunASynchronous>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
<settings pass="oobeSystem">
|
||||||
|
<component name="Microsoft-Windows-International-Core" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||||
|
<InputLocale>0409:00000409</InputLocale><!--Set your Keybaord and System Local https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-8.1-and-8/hh825682(v=win.10) -->
|
||||||
|
<SystemLocale>en-US</SystemLocale>
|
||||||
|
<UILanguage>en-US</UILanguage>
|
||||||
|
<UserLocale>en-US</UserLocale>
|
||||||
|
</component>
|
||||||
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS">
|
||||||
|
<OOBE>
|
||||||
|
<ProtectYourPC>3</ProtectYourPC> <!--Disable Diagnostic Data sent to Microsoft-->
|
||||||
|
<HideEULAPage>true</HideEULAPage><!--Hide the End User License agreement -->
|
||||||
|
<HideWirelessSetupInOOBE>false</HideWirelessSetupInOOBE> <!--Show Wifi Setup -->
|
||||||
|
</OOBE>
|
||||||
|
</component>
|
||||||
|
</settings>
|
||||||
|
</unattend>
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
||||||
<settings pass="specialize">
|
<settings pass="specialize">
|
||||||
|
<!--<ComputerName> must be in the first Component Element "Microsoft-Windows-Shell-Setup" . Do not change the order or remove it -->
|
||||||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="arm64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<ComputerName>MyComputer</ComputerName>
|
<ComputerName>MyComputer</ComputerName>
|
||||||
</component>
|
</component>
|
||||||
|
<!--Place addtional Components Elements and settings below here. -->
|
||||||
</settings>
|
</settings>
|
||||||
</unattend>
|
</unattend>
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
<unattend xmlns="urn:schemas-microsoft-com:unattend">
|
||||||
<settings pass="specialize">
|
<settings pass="specialize">
|
||||||
|
<!--<ComputerName> must be in the first Component Element "Microsoft-Windows-Shell-Setup" . Do not change the order or remove it -->
|
||||||
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<ComputerName>MyComputer</ComputerName>
|
<ComputerName>MyComputer</ComputerName>
|
||||||
</component>
|
</component>
|
||||||
|
<!--Place addtional Components Elements and settings below here. -->
|
||||||
</settings>
|
</settings>
|
||||||
</unattend>
|
</unattend>
|
||||||
Reference in New Issue
Block a user