Tag: DISM

Install Updates on Nano Server

How to install Updates on Nano Server

Microsoft just released Windows Server 2016, which comes with a new deployment option called Nano Server. Nano Server is a very small version of Windows Server which addresses a lot of different issues. Now after the release of Windows Server 2016 Microsoft is releasing the first updates for Windows Server 2016 and Nano Server.

Microsoft released the first Cumulative Update for Windows Server 2016 was released on September 26, 2016 (KB3192366) and the prerequisite for this and future Cumulative Update is the Servicing Stack Update for Windows 10 Version 1607 (KB3176939).

Download

You can download the .msu updates from the Windows Server Catalog:

Folder Structure

Just to make it easier for you, here is the folder structure I use:

  • C:\NanoServer – The Folder where I put all my files and folders to create and manage NanoServer. I copied the NanoServerImageGenerator PowerShell module to this folder
    Nano Server Folder
  • C:\NanoServer\Files – Copied all the files from the Windows Server 2016 ISO file
    Nano Server ISO Folder
  • C:\NanoServer\Updates – Downloaded .msu files and extracted .cab files
    Nano Server Update Folder
  • C:\NanoServer\Images – Created Nano Server Images

Extract the .cab files from the .msu file

For the most update scenarios you will need the .cab update package , which is included in the .msu file. To extract the .cab file from the .msu file you can use the expand command line utility.

In my case renamed the .msu files to for easier identification and copied both files to C:\NanoServer\Updates.

nano Server Epxand MSU Update Files

expand .\KB3176936.msu -F:* C:\NanoServer\Updates\
 
expand .\KB3192366.msu -F:* C:\NanoServer\Updates\

Integrate Updates into a new Nano Server Image

If you create a new Nano Server Image you can simply include the latest updates and cumulative updates while building the image. With that you have a new fresh NanoServer Image which will be fully patched after the first boot.

New Nano Server Image with Updates

Import-Module .\Files\NanoServer\NanoServerImageGenerator\NanoServerImageGenerator.psm1
 
New-NanoServerImage -MediaPath .\Files -BasePath .\Base -TargetPath .\Images\NanoVM.vhd -MaxSize 20GB -DeploymentType Guest -Edition Datacenter -ComputerName "Nano01" -ServicingPackagePath ".\Updates\Windows10.0-KB3176936-x64.cab", ".\Updates\Windows10.0-KB3176936-x64.cab"

Integrate Updates into an existing Nano Server Image

If you already have an existing Nano Server Image you can also updates this one.

Add Updates to Nano Server Image

Import-Module .\Files\NanoServer\NanoServerImageGenerator\NanoServerImageGenerator.psm1
 
Edit-NanoServerImage -TargetPath .\Images\NanoServer.wim -ServicingPackagePath ".\Updates\Windows10.0-KB3176936-x64.cab", ".\Updates\Windows10.0-KB3176936-x64.cab"

Integrate Updates into an VHD or VHDX (offline)

If you have VHD or VHDX templates and you want to integrate new updates you can do this as well using the DISM PowerShell module. You can also update existing Virtual Machines with this if you shutdown the VM (Offline Patching).

Mount-WindowsImage -ImagePath .\Images\NanoVM.vhdx -Path .\Mount -Index 1
 
Add-WindowsPackage -Path .\Mount -PackagePath  C:\NanoServer\Updates
 
Dismount-WindowsImage -Path .\Mount -Save

Install Updates on a running Nano Server (online)

If you have a running Nano Server in a virtual machine or on a physical host you can also use the downloaded .cap files and the DISM PowerShell module to install the patches on a Nano Server. For that you will need to use PowerShell remoting to connect to the Nano Server.

Install Updates on Nano Server

# Copy Update Files to Nano Server
$pssession = New-PSSession -VMName "NanoServer" -Credential (Get-Credential)
Invoke-Command -Session $pssession -ScriptBlock {md C:\Update}
Copy-Item -ToSession $pssession -Path C:\NanoServer\Updates\*.cab -Destination C:\Update\ -Recurse
 
# Install the servicing stack update first (reboot needed)
Enter-PSSession -ComputerName "NanoServer" -Credential (Get-Credential)
Add-WindowsPackage -Online -PackagePath C:\Update\Windows10.0-KB3176936-x64.cab
Restart-Computer
 
# Install update after reboot
Enter-PSSession -ComputerName (Read-Host "Enter Nano Server IP address") -Credential (Get-Credential)
Add-WindowsPackage -Online -PackagePath C:\Update\Windows10.0-KB3192366-x64.cab
Restart-Computer

If the Nano Server is running inside a VM, you can also use PowerShell Direct to connect directly to the Virtual Machine from the Hyper-V host.

Download and Install Updates on a running Nano Server from Windows Update (online from Windows Update)

If you have a running Nano Server VM or physical host, you can use the Windows Update WMI provider to download and install the update from Microsoft Update.

Enter-PSSession -ComputerName "NanoServer" -Credential (Get-Credential)
 
# Scan for updates
 
$ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
$result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=0";OnlineScan=$true}
$result.Updates
 
# Install all updates
 
$ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
Invoke-CimMethod -InputObject $ci -MethodName ApplyApplicableUpdates
 
Restart-Computer
 
# List Installed Updates
 
$ci = New-CimInstance -Namespace root/Microsoft/Windows/WindowsUpdate -ClassName MSFT_WUOperationsSession
$result = $ci | Invoke-CimMethod -MethodName ScanForUpdates -Arguments @{SearchCriteria="IsInstalled=1";OnlineScan=$true}
$result.Updates

Download and Install Updates on a running Nano Server from Windows Update using the Azure Remote Server Management Tools

You can also use a graphical UI to update Nano Server directly from the Remote Server Management Tools.

Install Updates on Nano Server from Server Management Tools SMT

You can get more information about Updating Nano Server on this Microsoft blog post.

 

 

 

 



diskpart-usb-drive

Create a USB Stick for Windows Server 2016 Installation

If you have download the latest version of Windows Server 2016 you can create a USB stick to install it on a physical server. This blog goes through how you create a USB Stick for Windows Server 2016.

For UEFI Systems:

  • The at least a 8GB USB drive has to be formatted in FAT32
  • The USB needs to be GPT and not MBR
  • Copy all files from the ISO to the USB drive

diskpart-usb-drive

This is it, and here is how you do it:

First plugin your USB drive to your computer. The USB drive should be bigger than 6GB.

Open a CMD prompt or PowerShell using the Run as Administrator option and open diskpart. Now you can do list all this by using

 
list disk

Select the USB disk, in my case this was disk 1

 
select disk 1

Clean the disk. Be careful this will remove all files and partitions on the USB media.

 
clean

Now convert it to GPT

 
convert gpt

Create a new primary partition. But make sure the partition is not greater than 16GB otherwise it can be formatted with FAT32.

 
create partition primary
 
# If your USB drive is bigger than 16GB use the following command
 
create partition primary size=16000

Format the partition with FAT32

 
format fs=FAT32 quick

Assign a drive letter to the volume

 
assign letter=k

now you can exit the diskpart and copy all files from the Windows or Windows Server to the USB drive and boot it. This works with Windows 8, Windows 8.1, Windows 10, Windows Server 2012, Windows Server 2012 R2 and Windows Server 2016 or even Hyper-V Server in the same editions.

For MBR systems:

  • The at least a 8GB USB drive has to be formatted in FAT32
  • The USB needs to be MBR
  • Partition need so be set active
  • Copy all files from the ISO to the USB drive

diskpart-usb-drive-mbr

 

This is it, and here is how you do it:

First plugin your USB drive to your computer. The USB drive should be bigger than 6GB.

Open a CMD prompt or PowerShell using the Run as Administrator option and open diskpart. Now you can do list all this by using

 
list disk

Select the USB disk, in my case this was disk 1

 
select disk 1

Clean the disk. Be careful this will remove all files and partitions on the USB media.

 
clean

Create a new primary partition. But make sure the partition is not greater than 16GB otherwise it can be formatted with FAT32.

 
create partition primary
 
# If your USB drive is bigger than 16GB use the following command
 
create partition primary size=16000

Format the partition with FAT32

 
format fs=FAT32 quick

Set Active

 
active

Assign a drive letter to the volume

 
assign letter=k

now you can exit the diskpart and copy all files from the Windows or Windows Server to the USB drive and boot it. This works with Windows 8, Windows 8.1, Windows 10, Windows Server 2012, Windows Server 2012 R2 and Windows Server 2016 or even Hyper-V Server in the same editions.

 

Important:

If Install.wim is larger than 4GB, you cannot copy the file to the drive, because of theFAT32 based partition limitation. The solutions for this is to split the wim file into smaller files.

split wim file using dism (you may have to change the drive letters):

 
dism /Split-Image /ImageFile:e:\sources\install.wim /SWMFile:k:\sources\install.swm /FileSize:4096

 



Windows 8 Logo

Add drivers to Windows 8 ISO Image

I already did a post how you can add drivers to your Windows 7 image with command line tools like dism and imagex. With Windows 8 you cannot use the command line tool imagex anymore, but you have a new Windows PowerShell module for dism which allows you to do the same. In this tutorial, I will add drivers to a Windows 8 ISO image.

First, I created three new folders:

  • Drivers – which includes all the extracted drivers for Windows 8
  • ISO – This consists of the extracted Windows 8 ISO image
  • Mount – This is an empty folder which will be used to mount the WIM files

PowerShell Dism Folders

First, we have to check in which Windows edition we want to add drivers. We can do this by using the Get-WindowsImage cmdlet:

 Get-WindowsImage -ImagePath .\ISO\sources\install.wim

Get-WindowsImage

This will show you all the Images which are included in this WIM file.

After we have seen the Index numbers, we can now mount the Windows Image our Mount folder. In my example, I use Image Index 3, which is the Windows Server 2012 Datacenter Core Edition. If you use Windows 8, you see other editions.

 Mount-WindowsImage -Path .\Mount -ImagePath .\ISO\sources\install.wim -Index 3

Mount-WindowsImage

After the image is mounted, we can now add the drivers from the Drivers folder.

 Add-WindowsDriver -Path .\Mount -Driver .\Drivers -Recurse

When all drivers are added to the Image, you can dismount the image and save it.

 Dismount-WindowsImage -Path .\Mount -Save

Dismount-WindowsImage

We have now added the drivers to the Install image, and you should also add the drivers to your boot image. To do this do the same steps to the .\ISO\sources\boot.wim.

After that, you can create an ISO file

oscdimg -n -m -bc:\temp\ISO\boot\etfsboot.com C:\temp\ISO C:\temp\mynew.iso


Windows Server

Add drivers to Windows Server 2012 ISO Image

I already did a post how you can add drivers to a Windows Server 2008 R2 installation image with the command line tools dism and imagex. With Windows Server 2012 you cannot use the command line tool imagex anymore but you have a new Windows PowerShell module for dism which allows you basically the same with. In this tutorial, I will add drivers to a Windows Server 2012 ISO image or a Microsoft Hyper-V Server Image.

First I created three new folders:

  • Drivers – which includes all the extracted drivers for Windows Server 2012 (I removed all the drivers which are not related to Windows Server 2012)
  • ISO – This includes the extracted Windows Server 2012 ISO image
  • Mount – This is an empty folder which will be used to mount the WIM files

PowerShell Dism Folders

First, we have to check in which Windows edition we want to add drivers. We can do this by using the Get-WindowsImage cmdlet:

 Get-WindowsImage -ImagePath .\ISO\sources\install.wim

Get-WindowsImage

This will show you all the Images which are included in this WIM file.

After we have seen the Index numbers we can now mount the Windows Image our Mount folder. In my example I use Image Index 3 which is the Windows Server 2012 Datacenter Core Edition

 Mount-WindowsImage -Path .\Mount -ImagePath .\ISO\sources\install.wim -Index 3

Mount-WindowsImage

After the image is mounted we can now add the drivers from the Drivers folder.

 Add-WindowsDriver -Path .\Mount -Driver .\Drivers -Recurse

When all drivers are added to the Image you can dismount the image and save it.

 Dismount-WindowsImage -Path .\Mount -Save

Dismount-WindowsImage

We have now added the drivers to the Install image, you should also add the drivers to your boot image. To do this just do the same steps to the .\ISO\sources\boot.wim.

After that, you can create an ISO file

oscdimg -n -m -bc:\temp\ISO\boot\etfsboot.com C:\temp\ISO C:\temp\mynew.iso

I hope this helps you to add drivers to a Windows Server ISO Image. If you have any questions, feel free to leave a comment.



Cisco UCS Hyper-V Cluster – Create Hyper-V Image for Blade Servers – Part 2

We use Microsoft Hyper-V Server 2008 R2 as Operating System for our Cisco Blade Notes. The Cisco UCS does need some special drivers which are not included in Hyper-V Server Image (Network and HBA). So I created a Hyper-V Server 2008 R2 ISO file which includes the Drivers from the Cisco UCS.

I made a blog post about adding Drivers to a Windows ISO, this is pretty much the same.

  1. First Download the Hyper-V Server 2008 R2 ISO from microsoft.com
  2. Download the Drivers from Cicso.com, you can download the Bundle File which also includes firmware.
  3. Download and install the Windows Automated Installation Kit
  4. Extract the Hyper-V ISO to C:\temp\hypervr2
  5. Extract the Windows Driver folder in the Cisco Driver ISO (In my case ucs-b2xx-drivers-1.3.1g.iso) to C:\temp\Drivers\Windows
  6. Create a folder for the WIM mount point C:\temp\WIM
    Folders
  7. Start Windows AIK Deployment Tools Command Prompt from Start menu
    Windows AIK Deployment Tools Command Prompt
  8. Now mount the install.wim file form the original Hyper-V Image (C:\temp\hypervr2\SOURCES) to C:\temp\WIM
    imagex /mountrw C:\temp\hypervr2\SOURCES\install.wim 1 C:\temp\wim
  9. Add Drivers with dism
    CD C:\temp\Drivers\Windows\Network\Emulex\M72KR\W2K8R2\x64
    dism /image:C:\temp\WIM /add-driver /driver:. /recurse
  10. After adding all drivers to the Image you can unmout the WIM Image
    imagex /unmount /commit C:\temp\wim
  11. Now create the new ISO file
    oscdimg -n -m -bc:\temp\hypervr2\boot\etfsboot.com C:\temp\hypervr2 C:\temp\hypervr2drivers.iso

Now you can use this new Image to deploy the Hyper-V Hosts on your Cisco UCS Blades.



Windows Server 2019 USB Drive

Add Drivers to Windows Installation ISO

If you have a Windows 7 or even a Windows Server 2008 R2 Server ISO file and you need to add drivers to this ISO file, this little how-to shows you how you can do that.

  1. First create the following folders
    C:\temp\WindowsISO (Unpack the windows.iso to this folder)
    C:\temp\drivers (Add all driver folders in this folder the drivers have to be in .inf format)
    C:\temp\wim (Is a temp folder for the WIM file)
    C:\ temp\WindowsISOdrivers (the new .ISO file will be created here)
  2. Download and install the Windows Automated Installation Kit
  3. Start Windows AIK Deployment Tools Command Prompt from Start menu
  4. Mount the install.wim file from C:\temp\WindowsISO to C:\temp\wim
    imagex /mountrw C:\temp\WindowsISO\SOURCES\install.wim 1 C:\temp\wim
  5. Add Drivers with dism
     CD C:\temp\drivers\Network\Emulex\M72KR\W2K8R2\x64
    dism /image:C:\temp\wim /add-driver /driver:. /recurse
  6. Now unmount the WIM Image
    imagex /unmount /commit C:\temp\wim
  7. Create the new ISO file
    oscdimg -n -m -bc:\temp\WindowsISO\boot\etfsboot.com C:\temp\WindowsISO C:\temp\WindowsISOdrivers\windows.iso


HowTo: Install Roles and Features Windows Server 2008 R2 Core (Shell)

This Guide should help you to install Roles and Features on Windows Server 2008 R2 per shell or on a Windows Server 2008 R2 Core Server.

Under Windows Server 2008 you could install Roles and Features with the command OCSETUP. Since we use Windows Server 2008 R2 Microsoft used the tool called DISM (Deployment Image Servicing and Management tool).

For checking availible Server roles type:

Dism /online /get-features /format:table

To enable a Feature or a Role, in this case the DNS Server Role, you just type:

Dism /online /enable-feature /featurename:DNS-Server-Core-Role