Sysprep windows server 2022

Type Your Question

 Sunday, 3 November 2024

WINDOWS SERVER 2022


Creating a Windows Server 2022 image using Sysprep (System Preparation Tool) allows you to efficiently deploy standardized server images across multiple machines. This process ensures consistency in configurations, settings, and applications, streamlining the server setup process. This guide provides a comprehensive and updated approach to Sysprep usage in Windows Server 2022.

Understanding Sysprep

Sysprep is a crucial utility included with Windows Server 2022. It facilitates the preparation of Windows installations for generalized distribution. Its main functions are:

  • Generalization: Sysprep removes machine-specific data and settings, like the computer name, security identifiers, and local user profiles, making the image reusable on various machines.
  • Audit Mode: Enables customization of the image, allowing you to install applications, configure drivers, and apply desired settings before the image is finalized.
  • Image Capture: Facilitates creating a bootable disk image from the prepared system.

Preparing the Windows Server 2022 Installation

Before running Sysprep, ensure the base Windows Server 2022 installation is set up according to your requirements. Here’s what to consider:

  • Install All Required Features: Include necessary roles, features, and drivers. For instance, if you need Active Directory Domain Services, install the relevant features during the initial installation or through Server Manager.
  • Install Applications: Install any critical applications needed in the server image, like databases, web servers, or security software. This is crucial to ensure consistency across all deployments.
  • Configure Security Settings: Set appropriate security policies, including user account restrictions, firewall rules, and group policies, for the desired level of security. These settings will be inherited by the deployments made from the image.
  • Optimize Disk Space: Delete unnecessary files and optimize disk space on the source machine. This reduces the final image size, enhancing deployment speeds. You can leverage tools like Disk Cleanup for this task.

Running Sysprep

After your Windows Server 2022 installation is complete, you can start the Sysprep process. Here’s how:

  1. Access System Preparation Tool: Press the «Windows Key + R,» type %systemroot%\system32\sysprep\sysprep.exe, and press Enter to launch the Sysprep GUI.
  2. Choose Your Options: In the System Preparation Tool, select these options:
    • System Cleanup Action: Choose either «Enter System Out-of-Box Experience (OOBE)» or «Generalize» for clean installations or customized deployments respectively.
    • Audit Mode: Select «Audit Mode» for applying customizations in the cloned image. This allows installing further applications, drivers, or configuring other settings before committing the image.
    • Shutdown Options: Choose «Shutdown» to automatically restart the machine after Sysprep finishes, enabling the subsequent image capture.

  3. Generalize and Shut Down: If using Generalize, be sure to have your appropriate drivers already included before you go through the generalizing steps.
  4. Start System Preparation: Click «OK» to start Sysprep.

Creating a Disk Image

After the system shuts down, you’re ready to capture the prepared Windows Server 2022 image. Common disk imaging tools include:

  • Windows Deployment Services (WDS): Provides a network-based image deployment solution integrated with Windows Server. WDS offers a comprehensive and manageable deployment experience.
  • Windows Server Backup: Integrated into Windows Server, it allows creating a backup image of the system disk. This image can then be used for restoring the server or deploying it to another machine.
  • Third-Party Imaging Software: Several specialized tools like Acronis True Image, Macrium Reflect, and EaseUS Todo Backup are available for more advanced features and flexibility in creating and deploying images.

Deploying the Image

Once you have a disk image of your prepared Windows Server 2022 installation, you can deploy it on different machines. Here’s how:

  • Using WDS: You can configure the network infrastructure and capture the image in WDS to seamlessly deploy it over the network.
  • From a USB or DVD: Create a bootable USB or DVD drive containing the image and boot the destination machines from it to initiate the deployment.
  • Using Virtual Machine Environments: If using virtualization software like Hyper-V, you can create a virtual machine using the captured image.

Troubleshooting

Here are some common problems and solutions you may encounter:

  • Sysprep Failure: Errors during the Sysprep process are often related to machine-specific settings or software not being removed. Re-check that you’ve configured everything correctly before the Sysprep command, and ensure that all applications have an applicable uninstallation process available on your system before executing the generalizing steps.
  • Driver Issues: If you’re experiencing problems with driver loading, ensure all necessary drivers are already integrated and loaded before initiating Sysprep.
  • Application Conflicts: Some applications might interfere with Sysprep. It’s helpful to create a list of required applications and verify that all the application components are compatible with the image deployment process.
  • Security Settings: Misconfigured security policies might also lead to Sysprep problems. Re-check the policies to avoid blocking any needed operations.

Best Practices

Follow these best practices to ensure a smooth image creation and deployment experience:

  • Use a Clean Installation: Start with a clean installation of Windows Server 2022 on the source machine before adding the required roles, features, and applications. This minimizes the chances of conflicts.
  • Test Thoroughly: Always test the deployment of the created image on a test system before implementing it on critical servers.
  • Keep Images Updated: Periodically update your server image with the latest patches, security updates, and application upgrades.
  • Documentation: Maintain a record of configurations and applied changes to the server image. This information helps during troubleshooting and future maintenance.

Conclusion

Using Sysprep and a good image capture method, you can effectively create and manage standard Windows Server 2022 images. The process streamlines server deployments and helps you build consistent configurations for your server environment, minimizing errors and ensuring efficient administration.

Sysprep Imaging 

 View : 27


Related


Translate :        

Hyper-V
Windows Server 2022

PreRequest :
Hyper-v installation #

Create Windows server 2022 VM . #

To Create First VM, Open PowerShell as administrator and run this commands:

# This script is in two parts. First we declare the variables to be applied.
$vm = "Master2022" # name of VM, this just applies in Windows, it isn't applied to the OS guest itself.
$image = "D:\images\SERVER_2022_EVAL_x64FRE_en-us.iso"
$vmswitch = "NAT" # name of your local vswitch
$port = "port1" # port on the VM
$vlan = 1 # VLAN that VM traffic will be send in
$cpu =  2 # Number of CPUs
$ram = 4GB # RAM of VM. Note this is not a string, not in quotation marks
$path_to_disk = "d:\Hyper-V\Virtual Hard Disks\" # Where you want the VM's virtual disk to reside
$disk_size = 20GB # VM storage, again, not a string

# Create a new VM
New-VM  $vm -Generation 2
# Set the CPU and start-up RAM
Set-VM $vm -ProcessorCount $cpu -MemoryStartupBytes $ram
# Create the new VHDX disk - the path and size.
New-VHD -Path $path_to_disk$vm-disk1.vhdx -SizeBytes $disk_size
# Add the new disk to the VM
Add-VMHardDiskDrive -VMName $vm -Path $path_to_disk$vm-disk1.vhdx
# Assign the OS ISO file to the VM
Add-VMDvdDrive -VMName $vm -Path $image
# Set DVD Drive as first bootrm
Set-VMFirmware -VMName $vm -FirstBootDevice ( Get-VMDvdDrive -VMName $vm)
# Remove the default VM NIC named 'Network Adapter'
Remove-VMNetworkAdapter -VMName $vm
# Add a new NIC to the VM and set its name
Add-VMNetworkAdapter -VMName $vm -Name $port
# Configure the NIC as access and assign VLAN
#Set-VMNetworkAdapterVlan -VMName $vm -VMNetworkAdapterName $port
# Connect the NIC to the vswitch
Connect-VMNetworkAdapter -VMName $vm -Name $port -SwitchName $vmswitch
Set-VM -Name $vm -CheckpointType Disabled
Disable-VMIntegrationService -VMName $vm "Time Synchronization"
Enable-VMIntegrationService -VMName $vm "Guest Service Interface"

Compleat windows installation with full desktop experience — not core installation. #

Start VM and compleat the installation & Make sue that windows is fully updated.
Open explorer and go to path C:\Windows\System32\Sysprep .
Run sysprep and select Generalize & Shutdown .
Wait till VM shutdown then take a copy or Zip the VM hard disk .

What We’re Doing

When you consider the installation, initial setup, updates, and configurations, setting up new virtual machines can take a while to deploy. Thankfully, this can be fixed by using templates! Simply create a new virtual machine, set it up the way you want it, then save it as a template so you can clone it later.

I’ll go through how I would configure a brand-new Windows Server 2022 virtual machine, walk through the entire creation process, and then turn it into a template so it can be quickly deployed at a later time.

Use the table of contents on the left to navigate between the different sections of the write-up as necessary. I go through every step of the process — so you can easily skip any that you don’t need to read.

Creating templates is only possible in VMware Workstation Pro, as VMware Workstation Player does not have the necessary components for creating templates, such as snapshots and cloning.

Getting the ISO Images

Download the bootable ISO image before you begin. The evaluation versions of Windows 10 and Windows Server 2022 are linked below. Download the corresponding ISO, though, if you’re using a different version.

Windows 10 Enterprise Evaluation

Windows Server 2022 Evaluation

Initial Installation

In the New Virtual Machine Wizard dialog box, I tend to choose to install the operating system later. This is to bypass easy install which is known to cause errors during the installation.

Choose Microsoft Windows and the version — in my case, Windows Server 2019 (that’s the latest option)

Choose a suitable name for the virtual machine and a location to save it.

Choose a drive capacity for the virtual machine — I am using 60GB for mine.

We need to mount the ISO before the wizard is finished. Click Customize Hardware… and navigate to the ISO you downloaded. After saving, review the rest of the settings and finish the wizard.

Windows Server Setup Process

After powering on the virtual machine and entering the installation process, select your language and regional settings.

The standard evaluation with the desktop experience should work for most everybody and that’s what I am going with as well.

Select Custom for the type of installation

Select the drive you configured earlier (should be the only drive)

After that, Windows Server should start installing. Go get some coffee; it might take a while.

Leveraging Audit Mode

What is audit mode?

With Audit mode, you can boot directly to the desktop environment and customize it according to your preferences. This includes installing drivers, checking for Windows updates, installing or uninstalling applications, creating new user accounts, and making other changes. Anything you do in Audit mode will be included in any virtual machines you create from this template, right from the start!

Please note that the installation will remain in audit mode until Sysprep is used to set the system to boot into OOBE (which we will cover shortly). This feature is beneficial because even if an update requires a restart, the system will boot back into audit mode until you are ready to proceed.

More information about audit mode (and the differences between the two boot modes) can be found here.

Booting into Audit Mode

When the installation is finished, you will be taken to the initial out-of-the-box experience screen (below). To bypass the OOBE setup and boot into the built-in administrator account, press CTRL+SHIFT+F3 on this screen.

Initial OOBE Screen for Windows Server

Once you do this, the virtual machine will reboot and log in as the built-in administrator, with the system preparation tool ready to use. You may close this for the time being, as we can always reload it if necessary (which we will).

Booted into Audit Mode

Customizing the Image

Now comes the fun part: personalizing the image! In my case, I’ll run Windows updates, install VMware tools, and configure BgInfo to display helpful host information right on the desktop.

Windows Updates

There isn’t much to do other than check for updates and let them install. When I create base images, I always try to keep them as up-to-date as possible.

Installing VMware tools improves virtual machine performance while enabling additional features such as copy/paste between the host and guest, higher display resolutions, and more.

Navigate to VM > Install VMware Tools… to mount the installer in the guest.

Once mounted, Windows will ask you what you want to do with the disk. Follow the standard installation procedure; after a few moments, the installation will be complete and ready to go.

I tend to wait to restart until Windows updates wants to reboot — because it most likely will.

Setting up BgInfo

BgInfo is a useful tool that displays information such as the hostname, IP address, and current user on the desktop. You can customize what is displayed, where it is displayed, and other properties from within the tool.

First, download BgInfo, unzip the archive, and put it where you want on the virtual machine — I put mine in C:\BGInfo.

Open Bginfo.exe and change which configuration items appear on the desktop. Once you’ve dialed in how you want it to look, apply the changes, and the desktop should now reflect the configuration items you selected.

To save the layout, go to File > Save As… and save it to the BgInfo folder extracted earlier (C:\BGInfo for me).

To make BgInfo run at startup for all users, create a new shortcut at C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup with the following location — C:\<bginfo_path>\Bginfo.exe C:\<bginfo_path>\<saved_template>.bgi /timer:0 /nolicprompt /silent

At this point, BgInfo will load the above-created template for every user who logs into the machine.

Finalizing the Template

Before we finish, some housekeeping is in order. After adding your final touches to the image, you should clean the component store to reduce the overall size of the final image. To do this, simply run the following command in an elevated command prompt:

dism /online /cleanup-image /StartComponentCleanup /ResetBase

To finish the setup and prepare the virtual machine to be used as a template, run Sysprep. Running Sysprep will cause the guest to boot into out-of-the-box experience mode, rather than audit mode as it usually would.

In a command prompt, load Sysprep by executing C:\Windows\System32\Sysprep\sysprep.exe, tick Generalize and choose Shutdown in the shutdown options dropdown.

Sysprep will run for a few minutes, then the virtual machine will shut down, and we’ll be ready for the next step.

Converting VM to a Template

Finally, we have reached the last step before deploying this template. To complete the process, navigate to the virtual machine settings > Options > Advanced and tick the «Enable Template mode» option.

Now that we have our template, we need to take a snapshot because this is what future clones will be based on. Navigate to VM > Snapshot > Take Snapshot…

Give it a name and a description, and then take the snapshot.

Using the Template

Now that we’ve converted this image to a template, we can simply clone it whenever we need to stand up a new virtual machine.

Go to Go to VM > Manage > Clone… to start the cloning process

Select an existing snapshot to clone from

Select between a linked clone or a full clone. I prefer full clones, but they consume a lot more resources, so selecting a linked clone can help with that.

Give your clone a name and a save location

All that remains is to boot up the new clone and go through the initial setup process as you would with any other install. This is possible because Sysprep performed the necessary work for the image to boot into OOBE rather than audit mode.

When you finish the setup, your new virtual machine will be ready to use with all of the modifications you made right out of the box!

From here on out, I have a fully functional Windows Server 2022 virtual machine ready to go in about 30 seconds.

Already set up out of the box!

That’s all I have for now! Thank you for sticking with me through this long post.

With Windows System Preparation Tool (Sysprep) tool, you can create customized Windows 10 or 11 reference images. You can install apps, drivers, and slipstream updates to a Windows installation image. After that, you can deploy Windows image to users’ computers within your company.

In this article, we’ll show how to use Sysprep to create the reference image of Windows 10 21H1 (19043.1320) and Windows 11 21H2 (22000.258) builds. Use this guide to create a Windows image that is ready and you can deploy it on a physical or virtual machine (VDI solutions).

What is SysPrep?

Before deploying a Windows image on users’ computers, you need to configure a reference image. Install the necessary drivers, applications, and configure other Windows settings. The resulting image must be generalized by deleting computer-specific information (SID, GUID, etc.). You can generalize the Windows image with the Sysprep utility.

Sysprep allows you to delete all the information related to a specific operating system instance. This includes unique identifiers (SID, GUID, etc.), the Windows activation reset, and installing apps and drivers in the Audit mode.

All the configuration of the operating system before you run Sysprep remains untouched. This includes the installed software, personalization and network settings, installed and pinned Metro apps on the start screen, File Explorer, and other parameters.

In Windows 10/11 and Windows Server 2019/2022, the Sysprep.exe utility is located in folder C:\Windows\System32\sysprep.

sysprep windows 10

After you installed a prepared reference Windows 10 image and configured in the correct way (with certain installed software, with the operating system settings, with the specified permissions and restrictions), you can deploy it to all computers of the company using MDT, WDS, SCCM or manually (take a look at Deploying Windows 10 with MDT and WDS).

Benefits and Disadvantages of Using Sysprep

Syprep’s benefits:

  • The customized reference Windows 10/11 image allows you to quickly deploy a ready-to-work environment on a user’s computer. You do not need to install drivers, programs, security updates. Also no need to configure custom Windows Settings on each computer;
  • You can deploy the Windows image using the answer (unattended) file. After the installation, you do not need to select the various options on the initial Windows 10 setup screen;
  • At any time, you can extract the image, make changes to it, and update it with the deployment tool.

Disadvantages of Sysprep:

  • The size of the Windows reference image can be significantly larger than the clean Windows 10 or 11 installation ISO image;
  • Periodically you have to update the versions of programs and drivers injected into the reference image, and install the latest security updates;
  • You cannot use the Sysprep tool on domain-joined computers. Sysprep will remove the computer from the AD domain;
  • You can run Sysprep up to 1001 times on a single Windows image. After reaching this limit, you should recreate your Windows image.

How to Create a Windows 10 or 11 Reference Image?

You can create your reference WIM image of Windows 11 or 10 through the following steps:

  1. Perform clean Windows 10/11 install from the ISO image, then enter the Audit Mode;
  2. Install apps, drivers, and configure the system settings;
  3. Prepare the operating system environment using the Sysprep utility;
  4. Boot into Windows PE and capture an image using the DISM tool.

Then, the resulting image WIM can be added to the installation disk or deployed using different tools such as MDT, WDS, DISM, or ImageX.

Customizing Windows 11 and 10 in Audit Mode with Sysprep

You need to customize your reference Windows Image in the Audit Mode. On the installed Windows 10/11 OS, you can boot Windows to Audit Mode or OOBE by pressing Shift + Ctrl + F3 on the OOBE (out-of-box experience user experience), or the Windows Welcome screen. You can also enter Audit Mode using Sysprep. To do this, open the Sysprep folder with File Explorer, hold down Shift, right-click on an empty space and select the Open PowerShell windows here or Open in Windows Terminal option.

Then run the command:

C:\windows\system32\sysprep\sysprep.exe
sysprep

In the System Preparation Tool window, select the options:

  • System Cleanup Action: Enter System Audit mode;
  • Shutdown Options: Reboot;
  • Press the OK button.

In our case, Sysprep is returning the following error:

System Preparation Tool 3.14

Sysprep was not able to validate your Windows installation. Review the log file at %WINDIR%\System32\Sysprep\Panther\setupact.log for details. After resolving the issue, use Sysprep to validate your installation again.

To find out the reason why Sysprep cannot start on your computer, press Win + R and run the command:

%WINDIR%\System32\Sysprep\Panther\setupact.log

Look for the Error lines in the setupact.log file. In our case, the error looks like this:

2021-11-19 06:12:56, Error SYSPRP Sysprep_Clean_Validate_Opk: Audit mode cannot be turned on if reserved storage is in use. An update or servicing operation may be using reserved storage.; hr = 0x800F0975

2021-11-19 06:12:56, Error SYSPRP ActionPlatform::LaunchModule: Failure occurred while executing ‘Sysprep_Clean_Validate_Opk’ from C:\Windows\System32\spopk.dll; dwRet = 0x975

2021-11-19 06:12:56, Error SYSPRP SysprepSession::Validate: Error in validating actions from C:\Windows\System32\Sysprep\ActionFiles\Cleanup.xml; dwRet = 0x975

2021-11-19 06:12:56, Error SYSPRP RunPlatformActions:Failed while validating Sysprep session actions; dwRet = 0x975

2021-11-19 06:12:56, Error [0x0f0070] SYSPRP RunDlls:An error occurred while running registry sysprep DLLs, halting sysprep execution. dwRet = 0x975

2021-11-19 06:12:56, Error [0x0f00d8] SYSPRP WinMain:Hit failure while pre-validate sysprep cleanup internal providers; hr = 0x80070975

windows 10 sysprep

In our case, the reason for the Sysprep error is specified here: “An update or servicing operation may be using reserved storage”. This means you cannot use Sysprep at this time, because your Windows image is locked by some changes. This can be installed updates, installation of Windows features, system programs, antiviruses, etc.

Go to Settings > Windows Updates. As you can see, there are several Pending Updates. Finish installing security updates, restart your computer, and run Sysprep again.

windows 10 sysprep guide

Tip. Another error “Sysprep was not able to validate your Windows installation” was covered in this guide.

The computer will automatically restart and boot to the Audit Mode. Windows automatically boots and logs in with the built-in administrator account when in the Audit Mode. Further, this account will be disabled.

sysprep windows 10 20h2

Windows 11/10 will boot in this mode no matter how many times you reboot your computer until the Sysprep is running.

There is only one visible sign to understand that you’ve entered the Windows Audit Mode desktop — the Sysprep dialog in the middle of the display. Do not close the Sysprep utility window — you will need it at the end of the configuration step. Minimize it.

In Audit Mode, you can configure your Windows reference image. We will take a look at several popular steps that sysops configure most often in their reference image.

Step 1: Install OEM Information and Logo

You can set your company branded info in the computer properties windows. In this example, we will configure OEMLogo, Company name, tech support website, and working hours. The easiest way to configure these settings is through the registry. Create a text file oem.reg, and copy the following code into it:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\OEMInformation]

“Logo”=”C:\\WINDOWS\\oem\\OEMlogo.bmp”

“Manufacturer”=”TheITBros, LLC”

“Model”=”Windows 10 Pro 21H1”

“SupportHours”=”9am to 5pm ET M-F”

“SupportURL”=”https://theitbros.com”

Note. First, create the graphic file C:\WINDOWS\oem\OEMlogo.bmp with your company logo.

To apply the reg file, double-click on it, and accept registry changes. As a result, these settings will be imported into the registry.

sysprep win10

After rebooting in the System Properties, you can see the following branded info:

sysprep answer file

Step 2: Install the Drivers and Apps

You can install drivers and third-party programs you would like to see in your Windows 10/11 image.
You can install programs manually, or using the Windows 10 package manager — Chocolatey.

Now install the Chocolatey. To do this, run the PowerShell console with administrator privileges. Enter the following commands:

Set-ExecutionPolicy Bypass -Scope Process -Force; `
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
how to sysprep windows 10

Restart the PowerShell console. Now you can install more programs with a single command.

Let’s say, we want to install Opera, Google Chrome, VLC media player, Adobe Acrobat Reader DC, 7Zip, K-Lite Codec Pack Full, and Zoomit using choco. Run the command:

choco install 7zip, Opera, googlechrome, vlc, adobereader, k-litecodecpackfull,zoom

Tip. You can find packages by their names with the command choco search opera.

On Windows 11, you can use the new built-in WinGet Package Manager to install the required software (about 3000 programs available in WinGet repo). To install the same set of programs, run the command:

winget install --id=7zip.7zip -e && winget install --id=Opera.Opera -e && winget install --id=Google.Chrome -e && winget install --id=VideoLAN.VLC -e && winget install --id=Adobe.Acrobat.Reader.32-bit -e && winget install --id=CodecGuide.K-LiteCodecPack.Full -e && winget install --id=Zoom.Zoom –e
sysprep windows 10 21h1

Tip. You can use the WinGet online repository browser (https://winstall.app/) to select the programs you want to install and generate the WinGet installation script.

sysprep step by step

You can also install drivers for all computers and laptops models on which you want to deploy this reference Windows 10/11 image. Download and extract the driver packages to a specific directory. Then search for all *.inf files, and inject all the drivers described there to the Windows image with the command:

for /f %i in ('dir /b /s *.inf') do pnputil.exe -i -a %i

If you need to reboot Windows to install the application or update, you can do it. After reboot, the system will return to audit mode.

Note. You can clean up your driver repository from driver duplicates using our script.

Step 3: Disable Telemetry and Data Collection in Windows 10/11

Windows 10 and 11 collect information about the operation of users on the computer. Examples of handwriting and voice samples, location information, error reports, calendar contents — all of these can be sent to Microsoft servers.

If you do not want the OS sending data to Microsoft’s telemetry servers, you can disable the Telemetry and Data Collection services. Run the elevated Command prompt, and execute the following commands:

sc delete DiagTrack
sc delete dmwappushservice
echo ““ > C:\ProgramData\Microsoft\Diagnosis\ETLLogs\AutoLogger\AutoLogger-DiagTrack-Listener.etl
REG ADD "HKLM\SOFTWARE\Policies\Microsoft\Windows\DataCollection" /v AllowTelemetry /t REG_DWORD /d 0 /f

Also, you can disable tracking in Windows 10 and 11 using the DisableWinTracking tool from GitHub.

Step 4: Install Windows Security Update in Audit Mode

Starting with Windows 8.1, you cannot install updates using the Windows Update Center in the Settings panel in the auditing mode. The Windows Update Center checks if the system has completed the OOBE stage. If not, the update won’t be performed.

To update the system from the console, you can take the PSWindowsUpdate Module from TechNet Gallery.

Save the PSWindowsUpdate.zip archive to a USB drive, and (this is important!) right-click on it > Properties > Unblock.

Extract the PSWindowsUpdate.zip to both folders:

  • %USERPROFILE%\Documents\Windows\PowerShell\Modules;
  • %WINDIR%\System32\Windows\PowerShell\v1.0\Modules.

To download and install all available Windows updates, run the commands:

PowerShell -ExecutionPolicy RemoteSigned -Command Import-Module PSWindowsUpdate;
Get-WUInstall -AcceptAll -IgnoreReboot

That’s all! Available updates will be downloaded from the Windows Update servers and installed automatically.

Step 5: Uninstall Built-in Microsoft Store Apps

Also, you can uninstall built-in UWM apps, but it’s really up to you. So, if you don’t want to uninstall built-in apps, just skip this step.

Here is a list of the pre-installed Microsoft apps in Windows 10 21H1.

Get-AppxPackage *3dbuilder* | Remove-AppxPackage
Get-AppxPackage *windowsalarms* | Remove-AppxPackage
Get-AppxPackage *windowscalculator* | Remove-AppxPackage
Get-AppxPackage *windowscommunicationsapps* | Remove-AppxPackage
Get-AppxPackage *windowscamera* | Remove-AppxPackage
Get-AppxPackage *officehub* | Remove-AppxPackage
Get-AppxPackage *skypeapp* | Remove-AppxPackage
Get-AppxPackage *getstarted* | Remove-AppxPackage
Get-AppxPackage *zunemusic* | Remove-AppxPackage
Get-AppxPackage *windowsmaps* | Remove-AppxPackage
Get-AppxPackage *solitairecollection* | Remove-AppxPackage
Get-AppxPackage *bingfinance* | Remove-AppxPackage
Get-AppxPackage *zunevideo* | Remove-AppxPackage
Get-AppxPackage *bingnews* | Remove-AppxPackage
Get-AppxPackage *onenote* | Remove-AppxPackage
Get-AppxPackage *people* | Remove-AppxPackage
Get-AppxPackage *windowsphone* | Remove-AppxPackage
Get-AppxPackage *photos* | Remove-AppxPackage
Get-AppxPackage *bingsports* | Remove-AppxPackage
Get-AppxPackage *soundrecorder* | Remove-AppxPackage
Get-AppxPackage *bingweather* | Remove-AppxPackage
Get-AppxPackage *xboxapp* | Remove-AppxPackage

The list of built-in MS Store Apps on Windows 11 21H2 has changed. Use the following PowerShell script to remove the preinstalled Windows 11 apps:

Remove built-in MS Store Apps on Windows 11 21H2:

#AV1 Codec
Get-AppxPackage *AV1VideoExtension* | Remove-AppxPackage
#News app
Get-AppxPackage *BingNews* | Remove-AppxPackage
#Weather
Get-AppxPackage *BingWeather* | Remove-AppxPackage
#PowerShell
Get-AppxPackage *PowerShell* | Remove-AppxPackage
#WebP image support
Get-AppxPackage *WebpImageExtension* | Remove-AppxPackage
#HEIF image support
Get-AppxPackage *HEIFImageExtension* | Remove-AppxPackage
#Windows Terminal
Get-AppxPackage *WindowsTerminal* | Remove-AppxPackage
#Music app
Get-AppxPackage *ZuneMusic* | Remove-AppxPackage
#Movies and TV
Get-AppxPackage *ZuneVideo* | Remove-AppxPackage
#MS Office
Get-AppxPackage *MicrosoftOfficeHub* | Remove-AppxPackage
#People app
Get-AppxPackage *People* | Remove-AppxPackage
#Maps
Get-AppxPackage *WindowsMaps* | Remove-AppxPackage
#Help and tips
Get-AppxPackage *GetHelp* | Remove-AppxPackage
#Voice Recorder
Get-AppxPackage *WindowsSoundRecorder* | Remove-AppxPackage
#Notepad
Get-AppxPackage *WindowsNotepad* | Remove-AppxPackage
#MS Paint
Get-AppxPackage *Paint* | Remove-AppxPackage
#Sticky Notes
Get-AppxPackage *MicrosoftStickyNotes* | Remove-AppxPackage
#PowerAutomate
Get-AppxPackage *PowerAutomateDesktop* | Remove-AppxPackage
#Xbox and related apps
Get-AppxPackage *Xbox* | Remove-AppxPackage
#Feedback Hub
Get-AppxPackage *WindowsFeedbackHub* | Remove-AppxPackage
#Microsoft To-Do
Get-AppxPackage *Todos* | Remove-AppxPackage
#Calculator
Get-AppxPackage *WindowsCalculator* | Remove-AppxPackage
#Alarms and Clocks
Get-AppxPackage *WindowsAlarms* | Remove-AppxPackage
#Teams/Chat
Get-AppxPackage *Teams* | Remove-AppxPackage
#Microsoft Edge
Get-AppxPackage *MicrosoftEdge* | Remove-AppxPackage
#Your Phone
Get-AppxPackage *YourPhone* | Remove-AppxPackage
#Spotify
Get-AppxPackage *SpotifyAB.SpotifyMusic* | Remove-AppxPackage
#Screen & Sketch/Snipping tool
Get-AppxPackage *ScreenSketch* | Remove-AppxPackage
#Solitaire Collection
Get-AppxPackage *MicrosoftSolitaireCollection* | Remove-AppxPackage
#Photos
Get-AppxPackage *Windows.Photos* | Remove-AppxPackage
#OneDrive
Get-AppxPackage *OneDriveSync* | Remove-AppxPackage
#Skype
Get-AppxPackage *SkypeApp* | Remove-AppxPackage
#Xbox Console Companion
Get-AppxPackage *GamingApp* | Remove-AppxPackage

Copy the list of commands for your Windows build, paste them into the PowerShell console, and press Enter:

Generalizing Windows 10/11 Image Using Sysprep

If your computer has a static IP address configured, specify that the address should be obtained automatically (from a DHCP server). You can do that in the network adapter settings.

sysprep tutorial

Or, you can use the following PowerShell script to automatically get an IP address from a DHCP server:

$IPType = "IPv4"
$adapter = Get-NetAdapter | ? {$_.Status -eq "up"}
$interface = $adapter | Get-NetIPInterface -AddressFamily $IPType
If ($interface.Dhcp -eq "Disabled") {
If (($interface | Get-NetIPConfiguration).Ipv4DefaultGateway) {
$interface | Remove-NetRoute -Confirm:$false
}
$interface | Set-NetIPInterface -DHCP Enabled
$interface | Set-DnsClientServerAddress -ResetServerAddresses
}

After everything is configured, you can run the Sysprep and select the options:

  • System Cleanup Action: Enter System Out-of-Box Experience (OOBE);
  • Shutdown Options: Shutdown;
  • Check the Generalize option.
sysprep guide

After generalizing the Windows image, it will start from Out-of-Box Experience (OOBE) mode and reassign unique SIDs during the first boot.

Using Answer Files with Sysprep for Unattended Windows 10/11 Installation

You can use an answer file together with the System Preparation (Sysprep) tool. It allows configuring unattended Windows Setup settings. This step is optional (used to automatically specify various parameters that must be configured when the image is at first run). You can skip this step, and go straight to the step of capturing a Windows image.

The answer file may contain the answer to each question. This must be selected when installing Windows and choosing the initial settings (region, language, product key, keyboard, account, and privacy setting, etc.). Follow the steps during the out-of-box experience (OOBE).

Due to the answer file, the number of installer screens is significantly reduced.

How to Create Windows 10 Answer File Using Windows System Image Manager?

You can create an answer file manually (this is simple XML). But it’s more convenient to generate the correct answer file using the Windows System Image Manager (SIM) tool. You can do it from the Windows Assessment and Deployment Kit (ADK).

Download the Windows Assessment and Deployment Kit (ADK) for Windows 10 or ADK for Windows 11. Use the ADK version for the Windows version you want to deploy.

Run the adksetup.exe file with administrator privileges. Then select Deployment Tools to install (it includes the latest version of DISM and Windows System Image Manager).

windows sysprep

You will need install.wim file with the Windows 10 or image you want to deploy. You can copy the install.wim file from the sources directory on the installation Windows 10 ISO image. If only the install.esd file is available in the sources directory, you can convert it to the install.wim.

Let’s create an answer unattended file for Windows 10 21H1.

Run the Windows System Image Manager with administrator privileges (C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Deployment Tools\WSIM\imgmgr.exe). Select File > New Answer File.

sysprep unattend.xml example windows 10

SIM will prompt you to specify a Windows image file for which you want to create an answer file. Specify the path to the before installed install.wim file.

Wait for the SIM to mount the Windows installation image and create the catalog file (.clg). This will take some time, after which the install_Windows 10 Pro.clg file will appear in the directory with the install.wim file.

windows 10 sysprep answer file

Note. If you try to open the install.wim file of your Windows 10 build using WSIM from an older version of the ADK, you may receive an error message:

Windows SIM was unable to generate a catalog

sysprep windows 10 step by step

In order to fix this error, you need to install the latest ADK and WSIM available for your Windows build.

Select your Windows 10 edition. If there is only one edition of Windows in your install.wim file, it will be selected automatically.

Using WSIM, you can configure various parameters for the answer file. For example, you can configure the Windows product key (if you are using KMS or MAK keys), time zone, organization and owner info, default language and region settings, input locales, etc.

First of all, we need to do the most important thing: to tell Sysprep to copy all our customizations to the default user profile.

To do this, in the Windows Image section, find the amd64_Microsoft-Windows-Shell-Setup__neutral section. Right-click on it and select Add Setting to Pass 4 specialize.

sysprep unattend.xml

Then, in the Answer File panel, expand section 4 Specialize > amd64_Microsoft-Windows-Shell-Setup__neutral. Set the CopyProfile value to TRUE.

sysprep with answer file

Additionally, you can configure the following options in the Answer file.

Pass 1 Windows PE

Choosing an installation language in WinPE:

Microsoft-Windows-International-Core-WinPE
InputLocale: en-US;
SystemLocale: en-US
UILanguage: en-US
UserLocale: en-US

The Windows 10 Product key:

Microsoft-Windows-Setup -> UserData -> ProductKey -> Key = {specify your MAK or GVLK key}

To automatically accept user agreement:

Microsoft-Windows-Setup -> UserData -> AccepptEula = True

Pass 7 oobeSystem

Skip Microsoft account creation screen (MSA):

Microsoft-Windows-Shell-Setup –> OOBE -> HideOnlineAccountScreens = True

Do not ask 3 security questions for your local account:

Microsoft-Windows-Shell-Setup –> OOBE -> ProtectYourPC= 3

Create a local administrator account and set a password for it:

Microsoft-Windows-Shell-Setup –> UserAccounts –> LocalAccounts -> Insert New Local Account
Name: admin
Group: Administrators
sysprep unattend

All empty (blank) answer file parameters must be removed.

To check the settings in answer files, select in Tools > Validate Answer File option. If you configured everything correctly, a message should appear in the Messages console: No warning or errors.

sysprep win 10

Save the answer file by choosing File > Save Answer File As > autounattend.xml.

Now you can close WSIM.

Generalize Windows Image Using Answer File

Now you can use your autounattend file to Sysprep your Windows 10 image. Run the elevated command prompt, and execute the following command (replace the path to autounattend.xml with yours):

c:\windows\System32\Sysprep\sysprep.exe /generalize /oobe /generalize /shutdown /unattend:C:\ps\autounattend.xml
sysprep command

With the /generalize option the Sysprep will remove unique computer data. This allows you to safely deploy this reference Windows 10 image on another workstation or laptop. After executing the command, the computer will shut down.

Capture Reference Windows 10/11 Using DISM after Generalize

After shutting down your computer, you can capture a customized Windows 10 image using MDT. You can also use other special tools for capturing a Windows image or using DISM. Below we will consider the DISM option.

Note. In previous versions of Windows, the ImageX tool could be used to capture and deploy an image. In the latest Windows 10 and 11 builds, you can do all this with DISM.

Boot the computer with the Windows reference image into Windows PE. You can do this by booting the computer from the Windows 10/11 installation disc, or recovery disc.

On the language selection screen, press Shift + F10.

In the command window that opens, type Diskpart command. Use the list vol command to identify the drive letters. In our example, the installed Windows image is located on drive D.

To capture the image, run the command:

dism /capture-image /imagefile:D:\win10referenceimg.wim /capturedir:d:\ /name:"Win10 Pro reference image"
sysprep location

/imagefile — the wim image file that we need to create;
/Capturedir — the reference Windows install folder.

how to create a windows 10 image for deployment sysprep

Copy the wim Image file from a local disk. Import it into your deployment software (MDT, SCCM), or put it on the installation drive (rename the file to install.wim).

I want to use System Preparation (Sysprep) to capture and install a custom reusable Windows Amazon Machine Image (AMI).

Resolution

When you run Sysprep, use the following best practices:

  • Don’t use Sysprep to create a backup for your instance.
  • Don’t run Sysprep on a production system.
  • Windows Server 2016 Nano Server doesn’t support Sysprep.
  • For Windows Server 2008 through Windows Server 2012 R2, run Sysprep with EC2Config.
  • For Windows Server 2016 or Windows 2019 (LTSC and SAC), run Sysprep with EC2Launch v1.
  • For Windows Server 2022 and Windows Server 2025, run Sysprep with EC2Launch v2. You can also use EC2Launch v2 for Windows 2012, 2012 R2, 2016 (LTSC and SAC), or 2019 (LTSC and SAC).

Note: For more information, see Limitations on the Microsoft website. To capture a Sysprep image of a production system, create an AMI from the instance. Then, launch the instance from the AMI in an isolated environment. You can capture a Sysprep image of the launched instance.

Run Sysprep with EC2Config or EC2Launch v1 or v2

Complete the following steps:

  1. Open the Amazon Elastic Compute Clouse (Amazon EC2) console.
  2. Use Remote Desktop Protocol (RDP) to connect to your Windows instance.
  3. Choose the Windows Start menu, and then complete one of the following steps for the Windows Server that you use:
    For Windows Server 2008 through Windows Server 2012 R2, open EC2ConfigService Settings, and then choose Image.
    For Windows Server 2016 or later, open EC2LaunchSettings.
  4. For Administrator Password, choose Random.
  5. Choose Shutdown with Sysprep, and then choose Yes.
    Note: You must retrieve the new password from the console the next time that you boot.
  6. Open the Amazon EC2 console.
  7. In the navigation pane, choose Instances.
  8. After the instance state changes to stopped, select your instance.
  9. For Actions, choose Image, and then choose Create image.
  10. For Image name, enter a name.
  11. For Image description, enter a description.
  12. Choose Create image.

For more information and customization options, see Create an Amazon EC2 AMI using Windows Sysprep.

If you receive error messages, then see Troubleshoot Sysprep issues with Amazon EC2 Windows instances. You can also use EC2Rescue for Windows Server to collect log files and troubleshoot any issues.

Related information

Why can’t I launch EC2 instances from my copied AMI?

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Очистка диска с на windows 10 cmd
  • Как изменить имя пользователя в windows 10 в папке пользователи администратор
  • Psiphon 3 для windows 10 torrent
  • Как получить права администратора для удаления программы в windows 10
  • Как поставить напоминание на компьютере windows 11