diff --git a/ChangeLog.md b/ChangeLog.md new file mode 100644 index 0000000..5340847 --- /dev/null +++ b/ChangeLog.md @@ -0,0 +1,229 @@ +# Change Log + +## **2406.1** + +This is a major release that includes the ability to download drivers from the 4 major OEMs (Microsoft, Dell, HP, Lenovo) by simply passing the -Make and -Model parameters to the command line. + +For Dell, HP, and Lenovo, the script leverages a similar process to their corresponding tools that automate driver downloads (Dell SupportAssist, HP Image Assistant, Lenovo System Update/Update Retriever). For Microsoft Surface, it scrapes the Surface Downloads page for the appropriate MSI file to download. Using this method, the drivers that are downloaded will be the latest provided by the OEM, unlike other tools that download out of date enteprise CAB files that are made for ConfigMgr. + +The script supports lookups using the -model parameter. For example, if you want to download the drivers for a Surface Laptop Go 3, but don't know the exact model name, you could set -Make 'Microsoft' -Model 'Laptop Go' and it'll give you a list of Surface devices to pick from. If you know the exact name, it'll use that and not prompt. + +![FFU Build Command Line that includes -make 'Microsoft' and -model 'Laptop Go' demonstrating how to use the new parameters to download drivers](image/ChangeLog/image-1.png) + +The goal here is to make it easy to discover the drivers you want to download without having to know the exact model names. + +There are likely going to be bugs with this, but in my testing things seem to work well for the makes and models that I've tried. If you notice something, please fill out an issue in the repro and I'll take a look. If you want to fix whatever issue you're running into, submit a pull request. + +### New parameters + +| Parameter | Type | Description | +| -------------- | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| Make | String | Used for automatically downloading drivers. Valid values are 'Microsoft', 'Dell', 'HP', 'Lenovo'. The script will throw an error if any other string value is used. | +| Model | String | Used for automatically downloading drivers with the Make parameter. | +| DriversFolder | String | Location where Drivers will either be downloaded, and/or the location of the drivers you wish to be added to the FFU, or copied to the deploy partition of the USB drive. The default location is $FFUDevelopmentPath\Drivers (e.g. C:\FFUDevelopmentPath\Drivers | +| CleanupDrivers | Bool | Used to delete the drivers folders underneath the `$DriversFolder` path (e.g. C:\FFUDevelopmentPath\Drivers\HP) after the FFU has been built. Default is `$true`true | +| UserAgent | String | The useragent string is used when invoking Invoke-Webrequest or Invoke-RestMethod. This has been helpful when interacting with the Microsoft Download Center and preventing intermittent errors. Default is Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0 | +| Headers | Hashtable | This hash table is used in conjunction with the Useragent when invoking Invoke-Webrequest or Invoke-RestMethod. This has been helpful when interacting with the Microsoft Download Center and preventing intermittent errors. If interested in the default value, reference the script itself. | + +### New Functions + +### `Test-URL` + +Simple function that accepts \$URL parameter to test if a URL is accessible. + +### `Start-BitsTransferWithRetry` + +This is simply Start-BITSTransfer with some retry logic and setting `$VerbosePreference` and `$ProgressPreference` to SilentlyContinue. The retry logic was needed due to certain driver files randomly failing to download. The function is hardcoded to retry 3 times before failing and will wait 5 seconds between each retry attempt. + +### `Get-MicrosoftDrivers` + +For Microsoft Surface, the driver files are hosted on the Microsoft download center. The script will scrape and parse the [Download Surface Drivers and Firmware](https://support.microsoft.com/en-us/surface/download-drivers-and-firmware-for-surface-09bb2e09-2a4b-cb69-0951-078a7739e120) page to get the latest list of Surface devices. + +This function accepts -Make, -Model, and -WindowsRelease parameters. Make and Model are both string parameters and WindowsRelease is an integer parameter. If the model parameter doesn't contain an exact match of a known Surface model, it'll give you a list of Surface models to pick from. + +The following command line says that we want to download the drivers for a Microsoft Laptop Go for Windows 10. + +`.\BuildFFUVM.ps1 -make 'Microsoft' -model 'Laptop Go' -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'external' -VMHostIPAddress '192.168.1.158' -CreateDeploymentMedia $true -BuildUSBDrive $true -UpdateLatestCU $true -UpdateLatestNet $true -UpdateLatestDefender $true -UpdateEdge $true -UpdateOneDrive $true -verbose -RemoveFFU $true -WindowsRelease 10` + +![Screenshot of the FFU script displaying a list of Surface models to download drivers for](image/ChangeLog/1718826099739.png) + +If you want to build an FFU for Surface Laptop Go 3, enter 18 and it'll download the MSI and extract the drivers to the .\FFUDevelopment\Drivers\Microsoft\Surface Laptop Go 3 folder. + +If you would have provided the exact model string instead of just Laptop Go (e.g. -Model 'Surface Laptop Go 3'), the script wouldn't prompt you to enter a valid model. + +### `Get-HPDrivers` + +For HP, the script uses the same process as the HP Image Assistant tool to automate the downloading of drivers. This function accepts the -Make, -Model, -WindowsArch, -WindowsRelease, and -WindowsVersion parameters. HP is the only vendor that uses -WindowsVersion (e.g. 23h2) for its drivers. This is because their XML files contain the -WindowsVersion value in the file name. By default, the script uses 23h2 for the -WindowsVersion parameter. You can override that for whatever -WindowsVersion you wish to use. + +The following command line says that we want to download HP x360 drivers for Windows 10 version 22h2. + +`.\BuildFFUVM.ps1 -make 'HP' -model 'x360' -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'external' -VMHostIPAddress '192.168.1.158' -CreateDeploymentMedia $true -CreateCaptureMedia $true -BuildUSBDrive $true -UpdateLatestCU $true -UpdateLatestNet $true -UpdateLatestDefender $true -UpdateEdge $true -UpdateOneDrive $true -RemoveFFU $true -WindowsRelease 10 -WindowsVersion '22h2' -Verbose` + +![Screenshot of the output of running the above command to download HP x360 drivers](image/ChangeLog/1718824392698.png) + +HP has 40 models that contain the string x360 in the model name. I want to select the HP ProBook x360 11 G7 Education Edition Notebook PC which is number 25. The below screenshot shows the output of selecting the HP ProBook x360 11 G7 Education Edition Notebook PC + +![Screenshot of the script downloading drivers for an HP ProBook x360 11 G7 Education Edition Notebook PC](image/ChangeLog/1718824500798.png) + +If you were to enter the exact model name (e.g. -model 'HP ProBook x360 11 G7 Education Edition Notebook PC'), the script wouldn't prompt you to select from a list of models. + +### `Get-LenovoDrivers` + +For Lenovo, the script uses the same process Lenovo System Update/Update Retriever use. It uses the Get-LenovoDrivers function which accepts -Model, -WindowsArch, -WindowsRelease parameters. + +Lenovo as a company doesn't use model like other companies do. Lenovo prefers to use a Machine Type value instead of Model number. The Machine Type value can be found on the bottom of your device as the first four characters of the MTM: value. Since most people don't know what the machine type value is, when passing the -model parameter, you can pass either the machine type or the "friendly" model number. + +The following command line says that we want to download Lenovo 500w drivers for Windows 10. + +`.\BuildFFUVM.ps1 -make 'Lenovo' -model '500w' -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'external' -VMHostIPAddress '192.168.1.158' -CreateDeploymentMedia $true -BuildUSBDrive $true -UpdateLatestCU $true -UpdateLatestNet $true -UpdateLatestDefender $true -UpdateEdge $true -UpdateOneDrive $true -RemoveFFU $true -WindowsRelease 10 -Verbose` + +The script will go out to the [Lenovo PSREF](https://psref.lenovo.com/search) page to figure out the Machine Type value and if multiple Machine Types are found (there are usually multiples found for different configuration types). + +![A screenshot of the different models and their machine types found from the Lenovo PSREF page and a selection prompt for the end user to pick which machine type they wish to use](image/ChangeLog/1718824806444.png) + +The Machine Type is the value in parenthesis. On the bottom of my device, the MTM value is MTM:**82VR**ZAKXXX. I would want to pick number 4 from the list since it includes (82VR). The below screenshot shows the script downloading the appropriate drivers for a Lenovo 500w. + +![The output of the script downloading Lenovo drivers](image/ChangeLog/1718824932640.png) + +If you use the Machine Type value for the -Model parameter (e.g. -model '82VR') the script will automatically download the drivers without prompting you to select the model. + +### `Get-DellDrivers` + +For Dell, the script uses the [Dell CatalogPC Cab file](http://downloads.dell.com/catalog/CatalogPC.cab) which is used in Dell Support Assist and possibly other Dell tools to download drivers. The cab consists of an XML file that the script parses to search for drivers applicable for the model you wish to create a FFU for. + +The script calls the Get-DellDrivers function which accepts the -Model and -WindowsArch parameters. + +Unlike Microsoft Surface drivers, Dell doesn't give a list to pick from when the -model parameter isn't an exact match. This is due to how the CatalogPC XML file lists drivers. It treats the driver as the primary element and lists what models that driver can be installed on. + +The following command line says that we want to download Dell 3190 drivers for Windows 10. + +`.\BuildFFUVM.ps1 -make 'Dell' -model '3190' -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'external' -VMHostIPAddress '192.168.1.158' -CreateDeploymentMedia $true -CreateCaptureMedia $true -BuildUSBDrive $true -UpdateLatestCU $true -UpdateLatestNet $true -UpdateLatestDefender $true -UpdateEdge $true -UpdateOneDrive $true -RemoveFFU $true -WindowsRelease 10 -Verbose` + +The script will find every driver that is tagged with 3190 and download the latest available version. It strips out any firmware or other non-driver file types. You may notice that it will download multiple video or audio drivers. This is due to each model having variants with different video cards or other hardware. This would make the FFU a bit larger, but not excessively so. + +Below is a screenshot of what the verbose output of the script looks like when downloading the drivers for a Dell 3190. + +![a screenshot of what the verbose output of the script looks like when downloading the drivers for a Dell 3190](image/ChangeLog/1718825319847.png) + +* Added -Headers \$Headers -UserAgent \$UserAgent to most Invoke-Webrequest or Invoke-RestMethod commands to solve for intermittent download failures when downloading drivers or Office +* Fixed some minor logging issues +* Updated the BuildDeployFFU.docx with new driver information and cleaned up some sections that were out of date +* Added Changelog.md to keep track of changes and not clutter up the readme.md + +## **2405.1** + +- Moved the resetbase command from within the VM to after servicing the VHDX. This will make it so the FFU size is smaller after the latest CU or .NET framework are installed. (Thanks to Mike Kelly for the PR [Commit](https://github.com/rbalsleyMSFT/FFU/pull/24)) +- Some additional FFU size reduction enhancements (Thanks Zehadi Alam [Commit](https://github.com/rbalsleyMSFT/FFU/pull/25)): + - Disk cleanup is now run before sysprep to help reduce FFU file size + - Before FFU capture, Optimize-FFU is run to defrag and slabconsolidate the VHDX + +## **2404.3** + +- Fixed an issue where the latest Windows CU wasn't downloading properly [Commit](https://github.com/rbalsleyMSFT/FFU/commit/ae59183a199f39b310c79b31c9b4980fafdeb79b) + +## **2404.2** + +- If setting `-installdrivers to $true` and `-logicalsectorsizebytes to 4096`, the script will now set `$copyDrivers to $true`. This will create a drivers folder on the deploy partition of the USB drive with the drivers that were supposed to be added to the FFU. There's currently a bug with servicing FFUs with 4096 logical sector byte sizes. Prior to this fix, the script would tell the user to manually set `-copydrivers to $true` as workaround. This fix just does the workaround automatically. + +## **2404.1** + +There's a big change with this release related to the ADK. The ADK will now be automatically updated to the latest ADK release. This is required in order to fix an issue with optimized FFUs not applying due to an issue with DISM/FFUProvider.dll. The FFUProvider.dll fix was added to the Sept 2023 ADK. Since we now have the ability to auto upgrade the ADK, I'm more confident in having the BuildFFUVM script creating a complete FFU now (prior it was only creating 3 partitions instead of 4 with the recovery partition - at deployment time, the ApplyFFU.ps1 script would create an empty recovery partition and Windows would populate it on first boot). Please open an issue if this creates a problem for you. I do realize that any new ADK release can have it's own challenges and issues and I do suspect we'll see a new ADK released later this year. + +- Allow for ISOs with single index WIMs to work [Issue 10](https://github.com/rbalsleyMSFT/FFU/issues/10) - [Commit](https://github.com/rbalsleyMSFT/FFU/commit/9e2da741d53652e6e600ca19cfd38f507bd01fde) +- Added more robust ADK handling. Will now check for the latest ADK and download it if not installed. Thanks to [Zehadi Alam](https://github.com/zehadialam) [PR 18](https://github.com/rbalsleyMSFT/FFU/pull/18) +- Revert code back to allow optimized FFUs to be applied via ApplyFFU.ps1 now that Sept 2023 ADK release has FFUProvider.dll fix. [Commit](https://github.com/rbalsleyMSFT/FFU/commit/79364e334d6d09ff150e70dab7bfb2637d0ad8a8) +- Changed how the script searches for the latest CU. Instead of relying on the Windows release info page to grab the KB number, will just use the MU Catalog, the same as what we do for the .NET Framework. Windows release info page is updated manually and is unknown as to when it will be updated. [Commit](https://github.com/rbalsleyMSFT/FFU/commit/6fd5a4a41fd9ce2f842f43dc3a69bda264c29fa6) +- Added fix to not allow computer names with spaces. Thanks to [JoeMama54 (Rob)](https://github.com/JoeMama54) [PR 20](https://github.com/rbalsleyMSFT/FFU/pull/20) + +## **2403.1** + +Fixed an issue with the SecurityHealthSetup.exe file giving an error when building the VM if -UpdateLatestDefender was set to $true. A new update for this came out on 3/21 which included a x64 and ARM64 binary. This file doesn't have an architecture designation to it, so it's impossible to know which file is for which architecture. Investigating to see if we can fix this in the Microsoft Update catalog. There is a web site to pull this from, but the support article is out of date. + +Included ADK functions from Zehadi Alam [Introduce Automated ADK Retrieval and Installation Functions #14](https://github.com/rbalsleyMSFT/FFU/pull/14) to automate the installation of the ADK if it's not present. Thanks, Zehadi! + +## **2402.1** + +**New functionality** + +* If -BuildUSBDrve $true, script will now check for USB drive before continuing. If not present, script exits +* Added a number of new parameters. + +| Parameter | Type | Description | +| -------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| CopyPEDrivers | Bool | When set to\$true, will copy the drivers from the \$FFUDevelopmentPath\PEDrivers folder to the WinPE deployment media. Default is \$false. | +| RemoveFFU | Bool | When set to\$true, will remove the FFU file from the\$FFUDevelopmentPath\FFU folder after it has been copied to the USB drive. Default is \$false. | +| UpdateLatestCU | Bool | When set to\$true, will download and install the latest cumulative update for Windows 10/11. Default is \$false. | +| UpdateLatestNet | Bool | When set to\$true, will download and install the latest .NET Framework for Windows 10/11. Default is \$false. | +| UpdateLatestDefender | Bool | When set to\$true, will download and install the latest Windows Defender definitions and Defender platform update. Default is \$false. | +| UpdateEdge | Bool | When set to\$true, will download and install the latest Microsoft Edge for Windows 10/11. Default is \$false. | +| UpdateOneDrive | Bool | When set to\$true, will download and install the latest OneDrive for Windows 10/11 and install it as a per machine installation instead of per user. Default is \$false. | +| CopyPPKG | Bool | When set to\$true, will copy the provisioning package from the \$FFUDevelopmentPath\PPKG folder to the Deployment partition of the USB drive. Default is \$false. | +| CopyUnattend | Bool | When set to\$true, will copy the \$FFUDevelopmentPath\Unattend folder to the Deployment partition of the USB drive. Default is \$false. | +| CopyAutopilot | Bool | When set to\$true, will copy the \$FFUDevelopmentPath\Autopilot folder to the Deployment partition of the USB drive. Default is \$false. | +| CompactOS | Bool | When set to\$true, will compact the OS when building the FFU. Default is \$true. | +| CleanupCaptureISO | Bool | When set to\$true, will remove the WinPE capture ISO after the FFU has been captured. Default is \$true. | +| CleanupDeployISO | Bool | When set to\$true, will remove the WinPE deployment ISO after the FFU has been captured. Default is \$true. | +| CleanupAppsISO | Bool | When set to\$true, will remove the Apps ISO after the FFU has been captured. Default is \$true. | + +* Updated the docs with the new variables and made some minor modifications. +* Changed version variable to 2402.1 + +## **2401.1** + +- Added -CopyDrivers boolean parameter to control the ability to copy drivers to the USB drive in the deploy partition drivers folder. +- Changed version varaible to 2401.1 +- When creating the scratch VHDX, switched it to create a dynamic VHDX instead of fixed +- Fixed an issue where adding drivers to the FFU would sometimes fail and would cause the script to exit unexpectedly +- Added -optimize boolean parameter to control whether the FFU is optimized or not. This defaults to $true and in most cases should be left this way. +- Fixed an issue where if the script failed to create the FFU and the old VM was left behind, it wouldn't clean it up if the VM was in the running state. Will now turn off any running VM with a name prefix of _FFU- and then remove any VMs with a name _FFU- if the environment is flagged as dirty. +- Fixed an issue where devices that ship with UFS drives were unable to image due to the script setting a LogicalSectorSizeBytes value of 512. If you're creating a FFU for devices that have UFS drives, you'll need to set -LogicalSectorSizeBytes 4096. +- There's a known issue where adding drivers to a FFU that has a LogicalSectorSizeBytes value of 4096. Added some code to prevent allowing this to happen. Please use -copydrivers $true as a workaround for now. We're investigating whether this is a bug or not. +- Fixed an issue where VHDX only captures (i.e. where -installapps $false) would not install Windows updates. +- Changed Office deployment to use Current channel instead of Monthly enterprise. If you want to change to Monthly Enterprise channel, it's recommended to leverage Intune. + +## **2309.2** + +New Features + +**Multiple USB Drive Support** + +You can now plug in multiple USB drives (even using a USB hub) to create multiple USB drives for deployment. This is great for partners or customers who need to provide USB drives to their employees to image a large number of devices. It will copy the content to one USB drive at a time. The most USB drives we've seen created so far is 23 via a USB hub. Open an issue if you see any problems with this. + +**Robocopy support** + +Replaced Copy-Item with Robocopy when copying content to the USB drive(s). Copy-Item uses buffered IO, which can take a long time to copy large files. Robocopy with the /J switch allows for unbuffered IO support, which reduces the amount of time to copy. + +**Better error handling** + +Prior to 2309.2, if the script failed or you manually killed the script (ctrl+c, or closing the PowerShell window), the environment would end up in a bad state and you had to do a number of things to manually clean up the environment. Added a new function called Get-FFUEnvironment and a new text file called dirty.txt that gets created in the FFUDevelopment folder. When the script starts, it checks for the dirty.txt file and if it sees it, Get-FFUEnvironment runs and cleans out a number of things to help ensure the next run will complete successfully. Open an issue if you still see problems when the script fails and the next run of the script fails.  + +Bug Fixes + +- In 2309.1, added a 15 second sleep to allow for the registry to unload to fix a Critical Process Died error on deployment. In this build, increased that to 60 seconds. +- Fixed an issue where the script was incorrectly detecting the USB drive boot and deploy drive letters which caused issues when attempting to copy the WinPE files to the boot partition. + +## **2309.1** + +- Fixed an issue with a Critical Process Died BSOD that would happen when using -installapps $false. More detailed information in the [commit](https://github.com/rbalsleyMSFT/FFU/pull/2/commits/34efbda7ec56dc7cb43ac42b058725d56c8b8899) + +## **2306.1.2** + +- Fixed an issue where manually entering a name wouldn't name the computer as expected + +## **2306.1.1** + +- Included some better error handling if defining optionalfeatures that require source folders (netfx3). ESD files don't have source folders like ISO media, which means installing .net 3.5 as an optional feature would fail. Also cleaned up some formatting. + +## **2306.1** + +- Added support to automatically download the latest Windows 10 or 11 media via the media creation tool (thanks to [Michael](https://oofhours.com/2022/09/14/want-your-own-windows-11-21h2-arm64-isos/) for the idea). This also allows for different architecture, language, and media type support. If you omit the -ISOPath, the script will download the Windows 11 x64 English (US) consumer media. + + An example command to download Windows 11 Pro x64 English (US) consumer media with Office and install drivers (it won't download drivers, you'll put those in your c:\FFUDevelopment\Drivers folder) + + .\BuildFFUVM.ps1 -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'Name of your VM Switch in Hyper-V' -VMHostIPAddress 'Your IP Address' -CreateCaptureMedia $true -CreateDeploymentMedia $true -BuildUSBDrive $true -verbose + + An example command to download Windows 11 Pro x64 French (CA) consumer media with Office and install drivers + + .\BuildFFUVM.ps1 -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'Name of your VM Switch in Hyper-V' -VMHostIPAddress 'Your IP Address' -CreateCaptureMedia $true -CreateDeploymentMedia $true -BuildUSBDrive $true -WindowsRelease 11 -WindowsArch 'x64' -WindowsLang 'fr-ca' -MediaType 'consumer' -verbose +- Changed default size of System/EFI partition to 260MB from 256MB to accomodate 4Kn drives. 4Kn support needs more testing. I'm not confident yet that this can be done with VMs and FFUs. +- Added versioning with a new version parameter. Using YYMM as the format followed by a point release. diff --git a/FFUDevelopment/BuildFFUVM.ps1 b/FFUDevelopment/BuildFFUVM.ps1 index dc4a6af..a011326 100644 --- a/FFUDevelopment/BuildFFUVM.ps1 +++ b/FFUDevelopment/BuildFFUVM.ps1 @@ -184,13 +184,19 @@ param( [string]$FFUDevelopmentPath = $PSScriptRoot, [bool]$InstallApps, [bool]$InstallOffice, + [ValidateSet('Microsoft', 'Dell', 'HP', 'Lenovo')] + [string]$Make, + [string]$Model, [Parameter(Mandatory = $false)] [ValidateScript({ - if ($_ -and (!(Test-Path -Path '.\Drivers') -or ((Get-ChildItem -Path '.\Drivers' -Recurse | Measure-Object -Property Length -Sum).Sum -lt 1MB))) { - throw 'InstallDrivers is set to $true, but either the Drivers folder is missing or empty' - } + if ($Make) { return $true - })] + } + if ($_ -and (!(Test-Path -Path '.\Drivers') -or ((Get-ChildItem -Path '.\Drivers' -Recurse | Measure-Object -Property Length -Sum).Sum -lt 1MB))) { + throw 'InstallDrivers is set to $true, but either the Drivers folder is missing or empty' + } + return $true + })] [bool]$InstallDrivers, [uint64]$Memory = 4GB, [uint64]$Disksize = 30GB, @@ -262,6 +268,9 @@ param( [bool]$Optimize = $true, [Parameter(Mandatory = $false)] [ValidateScript({ + if ($Make) { + return $true + } if ($_ -and (!(Test-Path -Path '.\Drivers') -or ((Get-ChildItem -Path '.\Drivers' -Recurse | Measure-Object -Property Length -Sum).Sum -lt 1MB))) { throw 'CopyDrivers is set to $true, but either the Drivers folder is missing or empty' } @@ -281,9 +290,27 @@ param( [bool]$CompactOS = $true, [bool]$CleanupCaptureISO = $true, [bool]$CleanupDeployISO = $true, - [bool]$CleanupAppsISO = $true + [bool]$CleanupAppsISO = $true, + [string]$DriversFolder, + [bool]$CleanupDrivers = $true, + [string]$UserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0', + #Microsoft sites will intermittently fail on downloads. These headers are to help with that. + $Headers = @{ + "Accept" = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7" + "Accept-Encoding" = "gzip, deflate, br, zstd" + "Accept-Language" = "en-US,en;q=0.9" + "Priority" = "u=0, i" + "Sec-Ch-Ua" = "`"Microsoft Edge`";v=`"125`", `"Chromium`";v=`"125`", `"Not.A/Brand`";v=`"24`"" + "Sec-Ch-Ua-Mobile" = "?0" + "Sec-Ch-Ua-Platform" = "`"Windows`"" + "Sec-Fetch-Dest" = "document" + "Sec-Fetch-Mode" = "navigate" + "Sec-Fetch-Site" = "none" + "Sec-Fetch-User" = "?1" + "Upgrade-Insecure-Requests" = "1" + } ) -$version = '2405.1' +$version = '2406.1' #Check if Hyper-V feature is installed (requires only checks the module) $osInfo = Get-WmiObject -Class Win32_OperatingSystem @@ -321,6 +348,7 @@ if (-not $KBPath) { $KBPath = "$FFUDevelopmentPath\KB" } if (-not $DefenderPath) { $DefenderPath = "$AppsPath\Defender" } if (-not $OneDrivePath) { $OneDrivePath = "$AppsPath\OneDrive" } if (-not $EdgePath) { $EdgePath = "$AppsPath\Edge" } +if (-not $DriversFolder) { $DriversFolder = "$FFUDevelopmentPath\Drivers" } #FUNCTIONS function WriteLog($LogText) { @@ -433,6 +461,811 @@ function Invoke-Process { } } + +function Test-Url { + param ( + [Parameter(Mandatory = $true)] + [string]$Url + ) + try { + # Create a web request and check the response + $request = [System.Net.WebRequest]::Create($Url) + $request.Method = 'HEAD' + $response = $request.GetResponse() + return $true + } + catch { + return $false + } +} + +# Function to download a file using BITS with retry and error handling +function Start-BitsTransferWithRetry { + param ( + [Parameter(Mandatory = $true)] + [string]$Source, + [Parameter(Mandatory = $true)] + [string]$Destination, + [int]$Retries = 3 + ) + + $attempt = 0 + while ($attempt -lt $Retries) { + try { + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $ProgressPreference = 'SilentlyContinue' + Start-BitsTransfer -Source $Source -Destination $Destination -ErrorAction Stop + $ProgressPreference = 'Continue' + $VerbosePreference = $OriginalVerbosePreference + return + } + catch { + $attempt++ + WriteLog "Attempt $attempt of $Retries failed to download $Source. Retrying..." + Start-Sleep -Seconds 5 + } + } + WriteLog "Failed to download $Source after $Retries attempts." + return $false +} + +function Get-MicrosoftDrivers { + param ( + [string]$Make, + [string]$Model, + [int]$WindowsRelease + ) + + $url = "https://support.microsoft.com/en-us/surface/download-drivers-and-firmware-for-surface-09bb2e09-2a4b-cb69-0951-078a7739e120" + + # Download the webpage content + WriteLog "Getting Surface driver information from $url" + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $webContent = Invoke-WebRequest -Uri $url -UseBasicParsing -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference + WriteLog "Complete" + + # Parse the content of the relevant nested divs + WriteLog "Parsing web content for models and download links" + $html = $webContent.Content + $nestedDivPattern = '
(.*?)
' + $nestedDivMatches = [regex]::Matches($html, $nestedDivPattern, [System.Text.RegularExpressions.RegexOptions]::Singleline) + + $models = @() + $modelPattern = '

(.*?)

\s*\s*\s*

\s*\|]', '_' + WriteLog "Downloading driver: $Name" + $Category = $update.Category + $Category = $Category -replace '[\\\/\:\*\?\"\<\>\|]', '_' + $Version = $update.Version + $Version = $Version -replace '[\\\/\:\*\?\"\<\>\|]', '_' + $DriverUrl = "https://$($update.URL)" + WriteLog "Driver URL: $DriverUrl" + $DriverFileName = [System.IO.Path]::GetFileName($DriverUrl) + $downloadFolder = "$DriversFolder\$ProductName\$Category" + $DriverFilePath = Join-Path -Path $downloadFolder -ChildPath $DriverFileName + + if (Test-Path -Path $DriverFilePath) { + WriteLog "Driver already downloaded: $DriverFilePath, skipping" + continue + } + + if (-not (Test-Path -Path $downloadFolder)) { + WriteLog "Creating download folder: $downloadFolder" + New-Item -Path $downloadFolder -ItemType Directory -Force | Out-Null + WriteLog "Download folder created" + } + + # Download the driver with retry + WriteLog "Downloading driver to: $DriverFilePath" + Start-BitsTransferWithRetry -Source $DriverUrl -Destination $DriverFilePath + WriteLog 'Driver downloaded' + + # Make folder for extraction + $extractFolder = "$downloadFolder\$Name\$Version\" + $DriverFileName.TrimEnd('.exe') + Writelog "Creating extraction folder: $extractFolder" + New-Item -Path $extractFolder -ItemType Directory -Force | Out-Null + WriteLog 'Extraction folder created' + + # Extract the driver + $arguments = "/s /e /f `"$extractFolder`"" + WriteLog "Extracting driver" + Invoke-Process -FilePath $DriverFilePath -ArgumentList $arguments + WriteLog "Driver extracted to: $extractFolder" + + # Delete the .exe driver file after extraction + Remove-Item -Path $DriverFilePath -Force + WriteLog "Driver installation file deleted: $DriverFilePath" + } + # Clean up the downloaded cab and xml files + Remove-Item -Path $DriverCabFile, $DriverXmlFile, $PlatformListCab, $PlatformListXml -Force + WriteLog "Driver cab and xml files deleted" +} +function Get-LenovoDrivers { + param ( + [Parameter()] + [string]$Model, + [Parameter()] + [ValidateSet("x64", "x86", "ARM64")] + [string]$WindowsArch, + [Parameter()] + [ValidateSet(10, 11)] + [int]$WindowsRelease + ) + + # Parse the Lenovo PSREF search page for machine types + function Get-LenovoPSREF { + param ( + [string]$ModelName + ) + + $url = "https://psref.lenovo.com/search" + WriteLog "Getting Lenovo PSREF page for model: $ModelName" + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $webContent = Invoke-WebRequest -Uri $url + $VerbosePreference = $OriginalVerbosePreference + WriteLog "Complete" + + # Access the parsed HTML + WriteLog "Parsing content" + $parsedHtml = $webContent.ParsedHtml + + # Select the nodes you are interested in + $productNameNodes = $parsedHtml.getElementsByTagName("li") | Where-Object { $_.className -contains "productname_li" } + $products = @() + # Iterate through the nodes + foreach ($product in $productNameNodes) { + $productA = $product.getElementsByTagName("a") | Where-Object { $_.tagName -eq "a" } + $innertext = @($productA.innertext) # Ensure innertext is treated as an array + $productName = $innertext[0] + + #if $productname contains 'Chromebook', skip the product + if ($productName -like '*Chromebook*') { + continue + } + $machineTypes = $innertext[1..($innertext.Count - 1)] + + if ($innertext -match $ModelName) { + foreach ($machineType in $machineTypes) { + If ($machineType -eq $modelName) { + WriteLog "Model name entered is a matching machine type" + $products = @() + $products += [pscustomobject]@{ + ProductName = $productName + MachineType = $machineType + } + WriteLog "Product Name: $productName Machine Type: $machineType" + continue + } + $products += [pscustomobject]@{ + ProductName = $productName + MachineType = $machineType + } + } + } + } + + return ,$products + } + + # Parse the Lenovo PSREF page for the model + $machineTypes = Get-LenovoPSREF -ModelName $Model + if ($machineTypes.Count -eq 0) { + WriteLog "No machine types found for model: $Model" + WriteLog "Enter a valid model or machine type in the -model parameter" + exit + } elseif ($machineTypes.Count -eq 1) { + $machineType = $machineTypes[0].MachineType + $model = $machineTypes[0].ProductName + } else { + if ($VerbosePreference -ne 'Continue'){ + Write-Output "Multiple machine types found for model: $Model" + } + WriteLog "Multiple machine types found for model: $Model" + for ($i = 0; $i -lt $machineTypes.Count; $i++) { + if ($VerbosePreference -ne 'Continue'){ + Write-Output "$($i + 1). $($machineTypes[$i].ProductName) ($($machineTypes[$i].MachineType))" + } + WriteLog "$($i + 1). $($machineTypes[$i].ProductName) ($($machineTypes[$i].MachineType))" + } + $selection = Read-Host "Enter the number of the model you want to select" + $machineType = $machineTypes[$selection - 1].MachineType + WriteLog "Selected machine type: $machineType" + $model = $machineTypes[$selection - 1].ProductName + WriteLog "Selected model: $model" + } + + + # Construct the catalog URL based on Windows release and machine type + $ModelRelease = $machineType + "_Win" + $WindowsRelease + $CatalogUrl = "https://download.lenovo.com/catalog/$ModelRelease.xml" + WriteLog "Lenovo Driver catalog URL: $CatalogUrl" + + if (-not (Test-Url -Url $catalogUrl)) { + Write-Error "Lenovo Driver catalog URL is not accessible: $catalogUrl" + WriteLog "Lenovo Driver catalog URL is not accessible: $catalogUrl" + exit + } + + # Create the folder structure for the Lenovo drivers + $driversFolder = "$DriversFolder\$Make" + if (-not (Test-Path -Path $DriversFolder)) { + WriteLog "Creating Drivers folder: $DriversFolder" + New-Item -Path $DriversFolder -ItemType Directory -Force | Out-Null + WriteLog "Drivers folder created" + } + + # Download and parse the Lenovo catalog XML + $LenovoCatalogXML = "$DriversFolder\$ModelRelease.xml" + WriteLog "Downloading $catalogUrl to $LenovoCatalogXML" + Start-BitsTransferWithRetry -Source $catalogUrl -Destination $LenovoCatalogXML + WriteLog "Download Complete" + $xmlContent = [xml](Get-Content -Path $LenovoCatalogXML) + + WriteLog "Parsing Lenovo catalog XML" + # Process each package in the catalog + foreach ($package in $xmlContent.packages.package) { + $packageUrl = $package.location + $category = $package.category + + #If category starts with BIOS, skip the package + if ($category -like 'BIOS*') { + continue + } + + #If category name is 'Motherboard Devices Backplanes core chipset onboard video PCIe switches', truncate to 'Motherboard Devices' to shorten path + if ($category -eq 'Motherboard Devices Backplanes core chipset onboard video PCIe switches') { + $category = 'Motherboard Devices' + } + + $packageName = [System.IO.Path]::GetFileName($packageUrl) + #Remove the filename from the $packageURL + $baseURL = $packageUrl -replace $packageName, "" + + # Download the package XML + $packageXMLPath = "$DriversFolder\$packageName" + WriteLog "Downloading $category package XML $packageUrl to $packageXMLPath" + If ((Start-BitsTransferWithRetry -Source $packageUrl -Destination $packageXMLPath) -eq $false) { + Write-Output "Failed to download $category package XML: $packageXMLPath" + WriteLog "Failed to download $category package XML: $packageXMLPath" + continue + } + + # Load the package XML content + $packageXmlContent = [xml](Get-Content -Path $packageXMLPath) + $packageType = $packageXmlContent.Package.PackageType.type + $packageTitle = $packageXmlContent.Package.title.InnerText + + # Fix the name for drivers that contain illegal characters for folder name purposes + $packageTitle = $packageTitle -replace '[\\\/\:\*\?\"\<\>\|]', '_' + + # If ' - ' is in the package title, truncate the title to the first part of the string. + $packageTitle = $packageTitle -replace ' - .*', '' + + #Check if packagetype = 2. If packagetype is not 2, skip the package. $packageType is a System.Xml.XmlElement. + #This filters out Firmware, BIOS, and other non-INF drivers + if ($packageType -ne 2) { + Remove-Item -Path $packageXMLPath -Force + continue + } + + # Extract the driver file name and the extract command + $driverFileName = $packageXmlContent.Package.Files.Installer.File.Name + $extractCommand = $packageXmlContent.Package.ExtractCommand + + #if extract command is empty/missing, skip the package + if (!($extractCommand)) { + Remove-Item -Path $packageXMLPath -Force + continue + } + + # Create the download URL and folder structure + $driverUrl = $baseUrl + $driverFileName + $downloadFolder = "$DriversFolder\$Model\$Category\$packageTitle" + $driverFilePath = Join-Path -Path $downloadFolder -ChildPath $driverFileName + + # Check if file has already been downloaded + if (Test-Path -Path $driverFilePath) { + Write-Output "Driver already downloaded: $driverFilePath skipping" + WriteLog "Driver already downloaded: $driverFilePath skipping" + continue + } + + if (-not (Test-Path -Path $downloadFolder)) { + WriteLog "Creating download folder: $downloadFolder" + New-Item -Path $downloadFolder -ItemType Directory -Force | Out-Null + WriteLog "Download folder created" + } + + # Download the driver with retry + WriteLog "Downloading driver: $driverUrl to $driverFilePath" + Start-BitsTransferWithRetry -Source $driverUrl -Destination $driverFilePath + WriteLog "Driver downloaded" + + # Make folder for extraction + $extractFolder = $downloadFolder + "\" + $driverFileName.TrimEnd($driverFileName[-4..-1]) + WriteLog "Creating extract folder: $extractFolder" + New-Item -Path $extractFolder -ItemType Directory -Force | Out-Null + WriteLog "Extract folder created" + + # Modify the extract command + $modifiedExtractCommand = $extractCommand -replace '%PACKAGEPATH%', "`"$extractFolder`"" + + # Extract the driver + # Start-Process -FilePath $driverFilePath -ArgumentList $modifiedExtractCommand -Wait -NoNewWindow + WriteLog "Extracting driver: $driverFilePath to $extractFolder" + Invoke-Process -FilePath $driverFilePath -ArgumentList $modifiedExtractCommand + WriteLog "Driver extracted" + + # Delete the .exe driver file after extraction + WriteLog "Deleting driver installation file: $driverFilePath" + Remove-Item -Path $driverFilePath -Force + WriteLog "Driver installation file deleted: $driverFilePath" + + # Delete the package XML file after extraction + WriteLog "Deleting package XML file: $packageXMLPath" + Remove-Item -Path $packageXMLPath -Force + WriteLog "Package XML file deleted" + } + + #Delete the catalog XML file after processing + WriteLog "Deleting catalog XML file: $LenovoCatalogXML" + Remove-Item -Path $LenovoCatalogXML -Force + WriteLog "Catalog XML file deleted" +} + +function Get-DellDrivers { + param ( + [Parameter(Mandatory = $true)] + [string]$Model, + [Parameter(Mandatory = $true)] + [ValidateSet("x64", "x86", "ARM64")] + [string]$WindowsArch + ) + + $catalogUrl = "http://downloads.dell.com/catalog/CatalogPC.cab" + if (-not (Test-Url -Url $catalogUrl)) { + WriteLog "Dell Catalog cab URL is not accessible: $catalogUrl Exiting" + if ($VerbosePreference -ne 'Continue') { + Write-Host "Dell Catalog cab URL is not accessible: $catalogUrl Exiting" + } + exit + } + + if (-not (Test-Path -Path $DriversFolder)) { + WriteLog "Creating Drivers folder: $DriversFolder" + New-Item -Path $DriversFolder -ItemType Directory -Force | Out-Null + WriteLog "Drivers folder created" + } + + $DriversFolder = "$DriversFolder\$Make" + WriteLog "Creating Dell Drivers folder: $DriversFolder" + New-Item -Path $DriversFolder -ItemType Directory -Force | Out-Null + WriteLog "Dell Drivers folder created" + + $DellCabFile = "$DriversFolder\CatalogPC.cab" + WriteLog "Downloading Dell Catalog cab file: $catalogUrl to $DellCabFile" + Start-BitsTransferWithRetry -Source $catalogUrl -Destination $DellCabFile + WriteLog "Dell Catalog cab file downloaded" + + $DellCatalogXML = "$DriversFolder\CatalogPC.XML" + WriteLog "Extracting Dell Catalog cab file to $DellCatalogXML" + Invoke-Process -FilePath Expand.exe -ArgumentList "$DellCabFile $DellCatalogXML" + WriteLog "Dell Catalog cab file extracted" + + $xmlContent = [xml](Get-Content -Path $DellCatalogXML) + $baseLocation = "https://" + $xmlContent.manifest.baseLocation + "/" + $latestDrivers = @{} + + $softwareComponents = $xmlContent.Manifest.SoftwareComponent | Where-Object { $_.ComponentType.value -eq "DRVR" } + foreach ($component in $softwareComponents) { + $models = $component.SupportedSystems.Brand.Model + foreach ($item in $models) { + if ($item.Display.'#cdata-section' -match $Model) { + $validOS = $component.SupportedOperatingSystems.OperatingSystem | Where-Object { $_.osArch -eq $WindowsArch } + if ($validOS) { + $driverPath = $component.path + $downloadUrl = $baseLocation + $driverPath + $driverFileName = [System.IO.Path]::GetFileName($driverPath) + $name = $component.Name.Display.'#cdata-section' + $name = $name -replace '[\\\/\:\*\?\"\<\>\|]', '_' + $name = $name -replace '[\,]', '-' + $category = $component.Category.Display.'#cdata-section' + $version = [version]$component.vendorVersion + $namePrefix = ($name -split '-')[0] + + # Use hash table to store the latest driver for each category to prevent downloading older driver versions + if ($latestDrivers[$category]) { + if ($latestDrivers[$category][$namePrefix]) { + if ($latestDrivers[$category][$namePrefix].Version -lt $version) { + $latestDrivers[$category][$namePrefix] = [PSCustomObject]@{ + Name = $name; + DownloadUrl = $downloadUrl; + DriverFileName = $driverFileName; + Version = $version; + Category = $category + } + } + } + else { + $latestDrivers[$category][$namePrefix] = [PSCustomObject]@{ + Name = $name; + DownloadUrl = $downloadUrl; + DriverFileName = $driverFileName; + Version = $version; + Category = $category + } + } + } + else { + $latestDrivers[$category] = @{} + $latestDrivers[$category][$namePrefix] = [PSCustomObject]@{ + Name = $name; + DownloadUrl = $downloadUrl; + DriverFileName = $driverFileName; + Version = $version; + Category = $category + } + } + } + } + } + } + + foreach ($category in $latestDrivers.Keys) { + foreach ($driver in $latestDrivers[$category].Values) { + $downloadFolder = "$DriversFolder\$Model\$($driver.Category)" + $driverFilePath = Join-Path -Path $downloadFolder -ChildPath $driver.DriverFileName + + if (Test-Path -Path $driverFilePath) { + Write-Output "Driver already downloaded: $driverFilePath skipping" + continue + } + + WriteLog "Downloading driver: $($driver.Name)" + if (-not (Test-Path -Path $downloadFolder)) { + WriteLog "Creating download folder: $downloadFolder" + New-Item -Path $downloadFolder -ItemType Directory -Force | Out-Null + WriteLog "Download folder created" + } + + WriteLog "Downloading driver: $($driver.DownloadUrl) to $driverFilePath" + try{ + Start-BitsTransferWithRetry -Source $driver.DownloadUrl -Destination $driverFilePath + WriteLog "Driver downloaded" + }catch{ + WriteLog "Failed to download driver: $($driver.DownloadUrl) to $driverFilePath" + continue + } + + + $extractFolder = $downloadFolder + "\" + $driver.DriverFileName.TrimEnd($driver.DriverFileName[-4..-1]) + WriteLog "Creating extraction folder: $extractFolder" + New-Item -Path $extractFolder -ItemType Directory -Force | Out-Null + WriteLog "Extraction folder created" + + $arguments = "/s /e=`"$extractFolder`"" + WriteLog "Extracting driver: $driverFilePath to $extractFolder" + Invoke-Process -FilePath $driverFilePath -ArgumentList $arguments + WriteLog "Driver extracted" + + WriteLog "Deleting driver file: $driverFilePath" + Remove-Item -Path $driverFilePath -Force + WriteLog "Driver file deleted" + } + } +} function Get-ADKURL { param ( [ValidateSet("Windows ADK", "WinPE add-on")] @@ -450,7 +1283,10 @@ function Get-ADKURL { try { # Retrieve content of Microsoft documentation page - $ADKWebPage = Invoke-RestMethod "https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install" + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $ADKWebPage = Invoke-RestMethod "https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install" -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference # Extract download URL based on specified pattern $ADKMatch = [regex]::Match($ADKWebPage, $ADKUrlPattern) @@ -469,7 +1305,10 @@ function Get-ADKURL { } # Retrieve headers of the FWlink URL + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' $FWLinkRequest = Invoke-WebRequest -Uri $ADKFWLink -Method Head -MaximumRedirection 0 -ErrorAction SilentlyContinue + $VerbosePreference = $OriginalVerbosePreference if ($FWLinkRequest.StatusCode -ne 302) { WriteLog "Failed to retrieve ADK download URL. Unexpected status code: $($FWLinkRequest.StatusCode)" @@ -514,7 +1353,7 @@ function Install-ADK { $installerLocation = Join-Path $env:TEMP $installer WriteLog "Downloading $ADKOption from $ADKUrl to $installerLocation" - Start-BitsTransfer -Source $ADKUrl -Destination $installerLocation -ErrorAction Stop + Start-BitsTransferWithRetry -Source $ADKUrl -Destination $installerLocation -ErrorAction Stop WriteLog "$ADKOption downloaded to $installerLocation" WriteLog "Installing $ADKOption with $feature enabled" @@ -606,7 +1445,7 @@ function Confirm-ADKVersionIsLatest { $installedADKVersion = $adkRegKey.GetValue("DisplayVersion") # Retrieve content of Microsoft documentation page - $adkWebPage = Invoke-RestMethod "https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install" + $adkWebPage = Invoke-RestMethod "https://learn.microsoft.com/en-us/windows-hardware/get-started/adk-install" -Headers $Headers -UserAgent $UserAgent # Specify regex pattern for ADK version $adkVersionPattern = 'ADK\s+(\d+(\.\d+)+)' # Check for regex pattern match @@ -720,7 +1559,10 @@ function Get-WindowsESD { # Download cab file WriteLog "Downloading Cab file" $cabFilePath = Join-Path $PSScriptRoot "tempCabFile.cab" - Invoke-WebRequest -Uri $cabFileUrl -OutFile $cabFilePath + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $cabFileUrl -OutFile $cabFilePath -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference WriteLog "Download succeeded" # Extract XML from cab file @@ -744,7 +1586,10 @@ function Get-WindowsESD { #Required to fix slow downloads $ProgressPreference = 'SilentlyContinue' WriteLog "Downloading $($file.filePath) to $esdFIlePath" - Invoke-WebRequest -Uri $file.FilePath -OutFile $esdFilePath + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $file.FilePath -OutFile $esdFilePath -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference WriteLog "Download succeeded" #Set back to show progress $ProgressPreference = 'Continue' @@ -758,9 +1603,12 @@ function Get-WindowsESD { } } + + function Get-ODTURL { - [String]$MSWebPage = Invoke-RestMethod 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117' + # [String]$MSWebPage = Invoke-RestMethod 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117' + [String]$MSWebPage = Invoke-RestMethod 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117' -Headers $Headers -UserAgent $UserAgent $MSWebPage | ForEach-Object { if ($_ -match 'url=(https://.*officedeploymenttool.*\.exe)') { @@ -774,11 +1622,13 @@ function Get-Office { $ODTUrl = Get-ODTURL $ODTInstallFile = "$env:TEMP\odtsetup.exe" WriteLog "Downloading Office Deployment Toolkit from $ODTUrl to $ODTInstallFile" - Invoke-WebRequest -Uri $ODTUrl -OutFile $ODTInstallFile + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + Invoke-WebRequest -Uri $ODTUrl -OutFile $ODTInstallFile -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference # Extract ODT WriteLog "Extracting ODT to $OfficePath" - # Start-Process -FilePath $ODTInstallFile -ArgumentList "/extract:$OfficePath /quiet" -Wait Invoke-Process $ODTInstallFile "/extract:$OfficePath /quiet" # Run setup.exe with config.xml and modify xml file to download to $OfficePath @@ -787,7 +1637,6 @@ function Get-Office { $xmlContent.Configuration.Add.SourcePath = $OfficePath $xmlContent.Save($ConfigXml) WriteLog "Downloading M365 Apps/Office to $OfficePath" - # Start-Process -FilePath "$OfficePath\setup.exe" -ArgumentList "/download $ConfigXml" -Wait Invoke-Process $OfficePath\setup.exe "/download $ConfigXml" WriteLog "Cleaning up ODT default config files and checking InstallAppsandSysprep.cmd file for proper command line" @@ -813,7 +1662,10 @@ function Get-KBLink { [Parameter(Mandatory)] [string]$Name ) - $results = Invoke-WebRequest -Uri "http://www.catalog.update.microsoft.com/Search.aspx?q=$Name" + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $results = Invoke-WebRequest -Uri "http://www.catalog.update.microsoft.com/Search.aspx?q=$Name" -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference $kbids = $results.InputFields | Where-Object { $_.type -eq 'Button' -and $_.Value -eq 'Download' } | Select-Object -ExpandProperty ID @@ -840,10 +1692,13 @@ function Get-KBLink { Write-Verbose -Message "Downloading information for $guid" $post = @{ size = 0; updateID = $guid; uidInfo = $guid } | ConvertTo-Json -Compress $body = @{ updateIDs = "[$post]" } - $links = Invoke-WebRequest -Uri 'https://www.catalog.update.microsoft.com/DownloadDialog.aspx' -Method Post -Body $body | + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $links = Invoke-WebRequest -Uri 'https://www.catalog.update.microsoft.com/DownloadDialog.aspx' -Method Post -Body $body -Headers $Headers -UserAgent $UserAgent | Select-Object -ExpandProperty Content | Select-String -AllMatches -Pattern "http[s]?://[^']*\.microsoft\.com/[^']*|http[s]?://[^']*\.windowsupdate\.com/[^']*" | Select-Object -Unique + $VerbosePreference = $OriginalVerbosePreference foreach ($link in $links) { $link.matches.value @@ -870,7 +1725,10 @@ function Get-LatestWindowsKB { } # Use Invoke-WebRequest to fetch the content of the page - $response = Invoke-WebRequest -Uri $updateHistoryUrl + $OriginalVerbosePreference = $VerbosePreference + $VerbosePreference = 'SilentlyContinue' + $response = Invoke-WebRequest -Uri $updateHistoryUrl -Headers $Headers -UserAgent $UserAgent + $VerbosePreference = $OriginalVerbosePreference # Use a regular expression to find the KB article number $kbArticleRegex = 'KB\d+' @@ -897,7 +1755,7 @@ function Save-KB { if ($WindowsArch -is [array]) { #Some file names include either x64 or amd64 if ($link -match $WindowsArch[0] -or $link -match $WindowsArch[1]) { - Start-BitsTransfer -Source $link -Destination $Path + Start-BitsTransferWithRetry -Source $link -Destination $Path $fileName = ($link -split '/')[-1] break } @@ -919,27 +1777,27 @@ function Save-KB { #Make sure we're getting the correct architecture for the Security Health Setup update if ($WindowsArch -eq 'x64'){ if ($link -match 'securityhealthsetup_e1'){ - Start-BitsTransfer -Source $link -Destination $Path + Start-BitsTransferWithRetry -Source $link -Destination $Path $fileName = ($link -split '/')[-1] break } } elseif ($WindowsArch -eq 'arm64'){ if ($link -match 'securityhealthsetup_25'){ - Start-BitsTransfer -Source $link -Destination $Path + Start-BitsTransferWithRetry -Source $link -Destination $Path $fileName = ($link -split '/')[-1] break } } continue } - Start-BitsTransfer -Source $link -Destination $Path + Start-BitsTransferWithRetry -Source $link -Destination $Path $fileName = ($link -split '/')[-1] } } else { if ($link -match $WindowsArch) { - Start-BitsTransfer -Source $link -Destination $Path + Start-BitsTransferWithRetry -Source $link -Destination $Path $fileName = ($link -split '/')[-1] break } @@ -1447,7 +2305,7 @@ function Optimize-FFUCaptureDrive { WriteLog 'Mounting VHDX for volume optimization' Mount-VHD -Path $VhdxPath WriteLog 'Defragmenting Windows partition...' - Optimize-Volume -DriveLetter W -Defrag -NormalPriority -Verbose + Optimize-Volume -DriveLetter W -Defrag -NormalPriority -Verbose WriteLog 'Performing slab consolidation on Windows partition...' Optimize-Volume -DriveLetter W -SlabConsolidate -NormalPriority -Verbose WriteLog 'Dismounting VHDX' @@ -1533,7 +2391,7 @@ function New-FFU { WriteLog 'Mounting complete' WriteLog 'Adding drivers - This will take a few minutes, please be patient' try { - Add-WindowsDriver -Path "$FFUDevelopmentPath\Mount" -Driver "$FFUDevelopmentPath\Drivers" -Recurse -ErrorAction SilentlyContinue | Out-null + Add-WindowsDriver -Path "$FFUDevelopmentPath\Mount" -Driver "$DriversFolder" -Recurse -ErrorAction SilentlyContinue | Out-null } catch { WriteLog 'Some drivers failed to be added to the FFU. This can be expected. Continuing.' @@ -1775,7 +2633,12 @@ Function New-DeploymentUSB { #Copy drivers using robocopy due to potential size if ($CopyDrivers) { WriteLog "Copying drivers to $DeployPartitionDriveLetter\Drivers" - robocopy "$FFUDevelopmentPath\Drivers" "$DeployPartitionDriveLetter\Drivers" /E /R:5 /W:5 /J + if ($Make){ + robocopy "$DriversFolder\$Make" "$DeployPartitionDriveLetter\Drivers" /E /R:5 /W:5 /J + }else{ + robocopy "$DriversFolder" "$DeployPartitionDriveLetter\Drivers" /E /R:5 /W:5 /J + } + } #Copy Unattend folder in the FFU folder to the USB drive. Can use copy-item as it's a small folder if ($CopyUnattend) { @@ -2016,7 +2879,46 @@ if (($InstallApps -eq $false) -and (($UpdateLatestDefender -eq $true) -or ($Upda } #Get script variable values -LogVariableValues +LogVariableValues + +#Check if environment is dirty +If (Test-Path -Path "$FFUDevelopmentPath\dirty.txt") { + Get-FFUEnvironment +} +WriteLog 'Creating dirty.txt file' +New-Item -Path .\ -Name "dirty.txt" -ItemType "file" | Out-Null + +#Get drivers first since user could be prompted for additional info +if (($make -and $model) -and ($installdrivers -or $copydrivers)) { + try { + if ($Make -eq 'HP'){ + WriteLog 'Getting HP drivers' + Get-HPDrivers -Make $Make -Model $Model -WindowsArch $WindowsArch -WindowsRelease $WindowsRelease -WindowsVersion $WindowsVersion + WriteLog 'Getting HP drivers completed successfully' + } + if ($make -eq 'Microsoft'){ + WriteLog 'Getting Microsoft drivers' + Get-MicrosoftDrivers -Make $Make -Model $Model -WindowsArch $WindowsArch -WindowsRelease $WindowsRelease + WriteLog 'Getting Microsoft drivers completed successfully' + } + if ($make -eq 'Lenovo'){ + WriteLog 'Getting Lenovo drivers' + Get-LenovoDrivers -Model $Model -WindowsArch $WindowsArch -WindowsRelease $WindowsRelease + WriteLog 'Getting Lenovo drivers completed successfully' + } + if ($make -eq 'Dell'){ + WriteLog 'Getting Dell drivers' + #Dell mixes Win10 and 11 drivers, hence no WindowsRelease parameter + Get-DellDrivers -Model $Model -WindowsArch $WindowsArch + WriteLog 'Getting Dell drivers completed successfully' + } + } + catch { + Writelog "Getting drivers failed with error $_" + throw $_ + } + +} #Get Windows ADK try { @@ -2029,13 +2931,6 @@ catch { throw $_ } -#Check if environment is dirty -If (Test-Path -Path "$FFUDevelopmentPath\dirty.txt") { - Get-FFUEnvironment -} -WriteLog 'Creating dirty.txt file' -New-Item -Path .\ -Name "dirty.txt" -ItemType "file" | Out-Null - #Create apps ISO for Office and/or 3rd party apps if ($InstallApps) { try { @@ -2073,6 +2968,7 @@ if ($InstallApps) { WriteLog "Searching for $Name from Microsoft Update Catalog and saving to $DefenderPath" $KBFilePath = Save-KB -Name $Name -Path $DefenderPath WriteLog "Latest Defender Platform and Definitions saved to $DefenderPath\$KBFilePath" + #Modify InstallAppsandSysprep.cmd to add in $KBFilePath on the line after REM Install Defender Update Platform WriteLog "Updating $AppsPath\InstallAppsandSysprep.cmd to include Defender Platform Update" $CmdContent = Get-Content -Path "$AppsPath\InstallAppsandSysprep.cmd" @@ -2102,7 +2998,7 @@ if ($InstallApps) { $DefenderDefURL = 'https://go.microsoft.com/fwlink/?LinkID=121721&arch=arm' } try { - Start-BitsTransfer -Source $DefenderDefURL -Destination "$DefenderPath\mpam-fe.exe" + Start-BitsTransferWithRetry -Source $DefenderDefURL -Destination "$DefenderPath\mpam-fe.exe" WriteLog "Defender Definitions downloaded to $DefenderPath\mpam-fe.exe" } catch { @@ -2120,6 +3016,7 @@ if ($InstallApps) { } #Download and Install OneDrive Per Machine if ($UpdateOneDrive) { + WriteLog "`$UpdateOneDrive is set to true, checking for latest OneDrive client" #Check if $OneDrivePath exists, if not, create it If (-not (Test-Path -Path $OneDrivePath)) { WriteLog "Creating $OneDrivePath" @@ -2128,7 +3025,7 @@ if ($InstallApps) { WriteLog "Downloading latest OneDrive client" $OneDriveURL = 'https://go.microsoft.com/fwlink/?linkid=844652' try { - Start-BitsTransfer -Source $OneDriveURL -Destination "$OneDrivePath\OneDriveSetup.exe" + Start-BitsTransferWithRetry -Source $OneDriveURL -Destination "$OneDrivePath\OneDriveSetup.exe" WriteLog "OneDrive client downloaded to $OneDrivePath\OneDriveSetup.exe" } catch { @@ -2162,9 +3059,9 @@ if ($InstallApps) { #Extract Edge cab file to same folder as $EdgeFilePath $EdgeMSIFileName = "MicrosoftEdgeEnterprise$WindowsArch.msi" $EdgeFullFilePath = "$EdgePath\$EdgeMSIFileName" - WriteLog "Extracting $EdgeCABFilePath" + WriteLog "Expanding $EdgeCABFilePath" Invoke-Process Expand "$EdgeCABFilePath -F:*.msi $EdgeFullFilePath" - WriteLog "Extraction complete" + WriteLog "Expansion complete" #Modify InstallAppsandSysprep.cmd to add in $KBFilePath on the line after REM Install Edge Stable WriteLog "Updating $AppsPath\InstallAppsandSysprep.cmd to include Edge Stable $WindowsArch release" @@ -2265,12 +3162,13 @@ try { if ($UpdateLatestCU -or $UpdateLatestNet) { try { WriteLog "Adding KBs to $WindowsPartition" + WriteLog 'This can take 10+ minutes depending on how old the media is and the size of the KB. Please be patient' Add-WindowsPackage -Path $WindowsPartition -PackagePath $KBPath -PreventPending | Out-Null WriteLog "KBs added to $WindowsPartition" WriteLog "Removing $KBPath" Remove-Item -Path $KBPath -Recurse -Force | Out-Null WriteLog "Clean Up the WinSxS Folder" - Invoke-Process cmd "/c ""$DandIEnv"" && Dism /Image:$WindowsPartition /Cleanup-Image /StartComponentCleanup /ResetBase" | Out-Null + Dism /Image:$WindowsPartition /Cleanup-Image /StartComponentCleanup /ResetBase | Out-Null WriteLog "Clean Up the WinSxS Folder completed" } catch { @@ -2523,8 +3421,24 @@ If ($CleanupAppsISO) { Writelog "Removing $AppsISO failed with error $_" throw $_ } +If ($CleanupDrivers){ + try { + If (Test-Path -Path $Driversfolder\$Make) { + WriteLog "Removing $Driversfolder\$Make" + Remove-Item -Path $Driversfolder\$Make -Force -Recurse + WriteLog "Removal complete" + } + } + catch { + Writelog "Removing $Driversfolder\$Make failed with error $_" + throw $_ + } + +} } #Clean up dirty.txt file Remove-Item -Path .\dirty.txt -Force | out-null -Write-Host "Script complete" -WriteLog "Script complete" +if ($VerbosePreference -ne 'Continue'){ + Write-Host 'Script complete' +} +WriteLog 'Script complete' diff --git a/FFUDevelopment/Docs/Archive/BuildDeployFFU.docx b/FFUDevelopment/Docs/Archive/BuildDeployFFU.docx new file mode 100644 index 0000000..8040f65 Binary files /dev/null and b/FFUDevelopment/Docs/Archive/BuildDeployFFU.docx differ diff --git a/FFUDevelopment/Docs/BuildDeployFFU.docx b/FFUDevelopment/Docs/BuildDeployFFU.docx index 8040f65..654003e 100644 Binary files a/FFUDevelopment/Docs/BuildDeployFFU.docx and b/FFUDevelopment/Docs/BuildDeployFFU.docx differ diff --git a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 index ad06c3c..c6b9491 100644 --- a/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 +++ b/FFUDevelopment/WinPEDeployFFUFiles/ApplyFFU.ps1 @@ -117,7 +117,7 @@ $LogFileName = 'ScriptLog.txt' $USBDrive = Get-USBDrive New-item -Path $USBDrive -Name $LogFileName -ItemType "file" -Force | Out-Null $LogFile = $USBDrive + $LogFilename -$version = '2405.1' +$version = '2406.1' WriteLog 'Begin Logging' WriteLog "Script version: $version" diff --git a/README.md b/README.md index b3c4ff8..a6939f3 100644 --- a/README.md +++ b/README.md @@ -7,122 +7,8 @@ This process will copy Windows in about 2-3 minutes to the target device, option While we use this in Education at Microsoft, other industries can use it as well. We esepcially see a need for something like this with partners who do re-imaging on behalf of customers. The difference in Education is that they typically have large deployments that tend to happen at the beginning of the school year and any amount of time saved is helpful. Microsoft Deployment Toolkit, Configuration Manager, and other community solutions are all great solutions, but are typically slower due to WIM deployments being file-based while FFU files are sector-based. # Updates -**2405.1** -- Moved the resetbase command from within the VM to after servicing the VHDX. This will make it so the FFU size is smaller after the latest CU or .NET framework are installed. (Thanks to Mike Kelly for the PR [Commit](https://github.com/rbalsleyMSFT/FFU/pull/24)) -- Some additional FFU size reduction enhancements (Thanks Zehadi Alam [Commit](https://github.com/rbalsleyMSFT/FFU/pull/25)): - - Disk cleanup is now run before sysprep to help reduce FFU file size - - Before FFU capture, Optimize-FFU is run to defrag and slabconsolidate the VHDX - -**2404.3** -- Fixed an issue where the latest Windows CU wasn't downloading properly [Commit](https://github.com/rbalsleyMSFT/FFU/commit/ae59183a199f39b310c79b31c9b4980fafdeb79b) - -**2404.2** - -- If setting -installdrivers to $true and -logicalsectorsizebytes to 4096, the script will now set $copyDrivers to $true. This will create a drivers folder on the deploy partition of the USB drive with the drivers that were supposed to be added to the FFU. There's currently a bug with servicing FFUs with 4096 logical sector byte sizes. Prior to this fix, the script would tell the user to manually set -copydrivers to $true as workaround. This fix just does the workaround automatically. - -**2404.1** - -There's a big change with this release related to the ADK. The ADK will now be automatically updated to the latest ADK release. This is required in order to fix an issue with optimized FFUs not applying due to an issue with DISM/FFUProvider.dll. The FFUProvider.dll fix was added to the Sept 2023 ADK. Since we now have the ability to auto upgrade the ADK, I'm more confident in having the BuildFFUVM script creating a complete FFU now (prior it was only creating 3 partitions instead of 4 with the recovery partition - at deployment time, the ApplyFFU.ps1 script would create an empty recovery partition and Windows would populate it on first boot). Please open an issue if this creates a problem for you. I do realize that any new ADK release can have it's own challenges and issues and I do suspect we'll see a new ADK released later this year. - -- Allow for ISOs with single index WIMs to work [Issue 10](https://github.com/rbalsleyMSFT/FFU/issues/10) - [Commit](https://github.com/rbalsleyMSFT/FFU/commit/9e2da741d53652e6e600ca19cfd38f507bd01fde) -- Added more robust ADK handling. Will now check for the latest ADK and download it if not installed. Thanks to [Zehadi Alam](https://github.com/zehadialam) [PR 18](https://github.com/rbalsleyMSFT/FFU/pull/18) -- Revert code back to allow optimized FFUs to be applied via ApplyFFU.ps1 now that Sept 2023 ADK release has FFUProvider.dll fix. [Commit](https://github.com/rbalsleyMSFT/FFU/commit/79364e334d6d09ff150e70dab7bfb2637d0ad8a8) -- Changed how the script searches for the latest CU. Instead of relying on the Windows release info page to grab the KB number, will just use the MU Catalog, the same as what we do for the .NET Framework. Windows release info page is updated manually and is unknown as to when it will be updated. [Commit](https://github.com/rbalsleyMSFT/FFU/commit/6fd5a4a41fd9ce2f842f43dc3a69bda264c29fa6) -- Added fix to not allow computer names with spaces. Thanks to [JoeMama54 (Rob)](https://github.com/JoeMama54) [PR 20](https://github.com/rbalsleyMSFT/FFU/pull/20) - -**2403.1** - -Fixed an issue with the SecurityHealthSetup.exe file giving an error when building the VM if -UpdateLatestDefender was set to $true. A new update for this came out on 3/21 which included a x64 and ARM64 binary. This file doesn't have an architecture designation to it, so it's impossible to know which file is for which architecture. Investigating to see if we can fix this in the Microsoft Update catalog. There is a web site to pull this from, but the support article is out of date. - -Included ADK functions from Zehadi Alam [Introduce Automated ADK Retrieval and Installation Functions #14](https://github.com/rbalsleyMSFT/FFU/pull/14) to automate the installation of the ADK if it's not present. Thanks, Zehadi! - -**2402.1** - -**New functionality** - -* If -BuildUSBDrve $true, script will now check for USB drive before continuing. If not present, script exits -* Added a number of new parameters. - -| Parameter | Type | Description | -| -------------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -| CopyPEDrivers | Bool | When set to\$true, will copy the drivers from the \$FFUDevelopmentPath\PEDrivers folder to the WinPE deployment media. Default is \$false. | -| RemoveFFU | Bool | When set to\$true, will remove the FFU file from the\$FFUDevelopmentPath\FFU folder after it has been copied to the USB drive. Default is \$false. | -| UpdateLatestCU | Bool | When set to\$true, will download and install the latest cumulative update for Windows 10/11. Default is \$false. | -| UpdateLatestNet | Bool | When set to\$true, will download and install the latest .NET Framework for Windows 10/11. Default is \$false. | -| UpdateLatestDefender | Bool | When set to\$true, will download and install the latest Windows Defender definitions and Defender platform update. Default is \$false. | -| UpdateEdge | Bool | When set to\$true, will download and install the latest Microsoft Edge for Windows 10/11. Default is \$false. | -| UpdateOneDrive | Bool | When set to\$true, will download and install the latest OneDrive for Windows 10/11 and install it as a per machine installation instead of per user. Default is \$false. | -| CopyPPKG | Bool | When set to\$true, will copy the provisioning package from the \$FFUDevelopmentPath\PPKG folder to the Deployment partition of the USB drive. Default is \$false. | -| CopyUnattend | Bool | When set to\$true, will copy the \$FFUDevelopmentPath\Unattend folder to the Deployment partition of the USB drive. Default is \$false. | -| CopyAutopilot | Bool | When set to\$true, will copy the \$FFUDevelopmentPath\Autopilot folder to the Deployment partition of the USB drive. Default is \$false. | -| CompactOS | Bool | When set to\$true, will compact the OS when building the FFU. Default is \$true. | -| CleanupCaptureISO | Bool | When set to\$true, will remove the WinPE capture ISO after the FFU has been captured. Default is \$true. | -| CleanupDeployISO | Bool | When set to\$true, will remove the WinPE deployment ISO after the FFU has been captured. Default is \$true. | -| CleanupAppsISO | Bool | When set to\$true, will remove the Apps ISO after the FFU has been captured. Default is \$true. | - -* Updated the docs with the new variables and made some minor modifications. -* Changed version variable to 2402.1 - -**2401.1** - -- Added -CopyDrivers boolean parameter to control the ability to copy drivers to the USB drive in the deploy partition drivers folder. -- Changed version varaible to 2401.1 -- When creating the scratch VHDX, switched it to create a dynamic VHDX instead of fixed -- Fixed an issue where adding drivers to the FFU would sometimes fail and would cause the script to exit unexpectedly -- Added -optimize boolean parameter to control whether the FFU is optimized or not. This defaults to $true and in most cases should be left this way. -- Fixed an issue where if the script failed to create the FFU and the old VM was left behind, it wouldn't clean it up if the VM was in the running state. Will now turn off any running VM with a name prefix of _FFU- and then remove any VMs with a name _FFU- if the environment is flagged as dirty. -- Fixed an issue where devices that ship with UFS drives were unable to image due to the script setting a LogicalSectorSizeBytes value of 512. If you're creating a FFU for devices that have UFS drives, you'll need to set -LogicalSectorSizeBytes 4096. -- There's a known issue where adding drivers to a FFU that has a LogicalSectorSizeBytes value of 4096. Added some code to prevent allowing this to happen. Please use -copydrivers $true as a workaround for now. We're investigating whether this is a bug or not. -- Fixed an issue where VHDX only captures (i.e. where -installapps $false) would not install Windows updates. -- Changed Office deployment to use Current channel instead of Monthly enterprise. If you want to change to Monthly Enterprise channel, it's recommended to leverage Intune. - -**2309.2** - -New Features - -**Multiple USB Drive Support** - -You can now plug in multiple USB drives (even using a USB hub) to create multiple USB drives for deployment. This is great for partners or customers who need to provide USB drives to their employees to image a large number of devices. It will copy the content to one USB drive at a time. The most USB drives we've seen created so far is 23 via a USB hub. Open an issue if you see any problems with this. - -**Robocopy support** - -Replaced Copy-Item with Robocopy when copying content to the USB drive(s). Copy-Item uses buffered IO, which can take a long time to copy large files. Robocopy with the /J switch allows for unbuffered IO support, which reduces the amount of time to copy. - -**Better error handling** - -Prior to 2309.2, if the script failed or you manually killed the script (ctrl+c, or closing the PowerShell window), the environment would end up in a bad state and you had to do a number of things to manually clean up the environment. Added a new function called Get-FFUEnvironment and a new text file called dirty.txt that gets created in the FFUDevelopment folder. When the script starts, it checks for the dirty.txt file and if it sees it, Get-FFUEnvironment runs and cleans out a number of things to help ensure the next run will complete successfully. Open an issue if you still see problems when the script fails and the next run of the script fails.  - -Bug Fixes - -- In 2309.1, added a 15 second sleep to allow for the registry to unload to fix a Critical Process Died error on deployment. In this build, increased that to 60 seconds. -- Fixed an issue where the script was incorrectly detecting the USB drive boot and deploy drive letters which caused issues when attempting to copy the WinPE files to the boot partition. - -**2309.1** - -- Fixed an issue with a Critical Process Died BSOD that would happen when using -installapps $false. More detailed information in the [commit](https://github.com/rbalsleyMSFT/FFU/pull/2/commits/34efbda7ec56dc7cb43ac42b058725d56c8b8899) - -**2306.1.2** - -- Fixed an issue where manually entering a name wouldn't name the computer as expected - -**2306.1.1** - -- Included some better error handling if defining optionalfeatures that require source folders (netfx3). ESD files don't have source folders like ISO media, which means installing .net 3.5 as an optional feature would fail. Also cleaned up some formatting. - -**2306.1** - -- Added support to automatically download the latest Windows 10 or 11 media via the media creation tool (thanks to [Michael](https://oofhours.com/2022/09/14/want-your-own-windows-11-21h2-arm64-isos/) for the idea). This also allows for different architecture, language, and media type support. If you omit the -ISOPath, the script will download the Windows 11 x64 English (US) consumer media. - - An example command to download Windows 11 Pro x64 English (US) consumer media with Office and install drivers (it won't download drivers, you'll put those in your c:\FFUDevelopment\Drivers folder) - - .\BuildFFUVM.ps1 -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'Name of your VM Switch in Hyper-V' -VMHostIPAddress 'Your IP Address' -CreateCaptureMedia $true -CreateDeploymentMedia $true -BuildUSBDrive $true -verbose - - An example command to download Windows 11 Pro x64 French (CA) consumer media with Office and install drivers - - .\BuildFFUVM.ps1 -WindowsSKU 'Pro' -Installapps $true -InstallOffice $true -InstallDrivers $true -VMSwitchName 'Name of your VM Switch in Hyper-V' -VMHostIPAddress 'Your IP Address' -CreateCaptureMedia $true -CreateDeploymentMedia $true -BuildUSBDrive $true -WindowsRelease 11 -WindowsArch 'x64' -WindowsLang 'fr-ca' -MediaType 'consumer' -verbose -- Changed default size of System/EFI partition to 260MB from 256MB to accomodate 4Kn drives. 4Kn support needs more testing. I'm not confident yet that this can be done with VMs and FFUs. -- Added versioning with a new version parameter. Using YYMM as the format followed by a point release. +2406.1 has been released! Check out the changes in the new [Change Log](ChangeLog.md) # Getting Started diff --git a/image/ChangeLog/1718823802250.png b/image/ChangeLog/1718823802250.png new file mode 100644 index 0000000..bf912b2 Binary files /dev/null and b/image/ChangeLog/1718823802250.png differ diff --git a/image/ChangeLog/1718824286743.png b/image/ChangeLog/1718824286743.png new file mode 100644 index 0000000..c4ff314 Binary files /dev/null and b/image/ChangeLog/1718824286743.png differ diff --git a/image/ChangeLog/1718824392698.png b/image/ChangeLog/1718824392698.png new file mode 100644 index 0000000..ab88466 Binary files /dev/null and b/image/ChangeLog/1718824392698.png differ diff --git a/image/ChangeLog/1718824500798.png b/image/ChangeLog/1718824500798.png new file mode 100644 index 0000000..609a88c Binary files /dev/null and b/image/ChangeLog/1718824500798.png differ diff --git a/image/ChangeLog/1718824806444.png b/image/ChangeLog/1718824806444.png new file mode 100644 index 0000000..050f3f8 Binary files /dev/null and b/image/ChangeLog/1718824806444.png differ diff --git a/image/ChangeLog/1718824932640.png b/image/ChangeLog/1718824932640.png new file mode 100644 index 0000000..b8eb63d Binary files /dev/null and b/image/ChangeLog/1718824932640.png differ diff --git a/image/ChangeLog/1718825319847.png b/image/ChangeLog/1718825319847.png new file mode 100644 index 0000000..81492a0 Binary files /dev/null and b/image/ChangeLog/1718825319847.png differ diff --git a/image/ChangeLog/1718826099739.png b/image/ChangeLog/1718826099739.png new file mode 100644 index 0000000..42aa31c Binary files /dev/null and b/image/ChangeLog/1718826099739.png differ diff --git a/image/ChangeLog/image-1.png b/image/ChangeLog/image-1.png new file mode 100644 index 0000000..85d21c0 Binary files /dev/null and b/image/ChangeLog/image-1.png differ