Tag: add

PowerShell Get-WindowsImage Windows Server 2019 Editions

Add Drivers to a Windows Server 2019 ISO Image

In this blog article, I am going to show you how you can add drivers to a Windows Server 2019 ISO Image or WIM file using PowerShell and the DISM module. This will allow you to already have the latest drivers within the Windows Server installation image when you install Windows Server 2019. We will add drivers to a Windows Server 2019 WIM file (WIM stands for Windows Imaging Format), which then can be used to create a new ISO image or for example in Windows Deployment Services.

Preparation

Folder for adding drivers to Windows Server 2019

Folder for adding drivers to Windows Server 2019

First, you will need to create three new folders called Drivers, ISO, and Mount. In my example, I created these in C:\Images.

  • Drivers – This is the folder where you put all your extracted drivers, which you want to add to your Windows Server 2019 Image.
  • ISO – This is where you can extract the Windows Server 2019 ISO Image. Basically all the files on the ISO file.
  • Mount – This is an empty folder, which will be used to mount the WIM files.

You can now mount the ISO using Windows Explorer or the following PowerShell commands and copy the files to the ISO folder.

Mount ISO PowerShell

Mount ISO PowerShell

Mount-DiskImage -ImagePath C:\Temp\17763.379.190312-0539.rs5_release_svc_refresh_SERVER_EVAL_x64FRE_en-us.iso
Copy-Item D:\* C:\Image\ISO\ -Recurse

In your case, the ISO may be mounted on a different drive letter instead of my D: drive.

Add drivers to the Windows Server 2019 Image

First, you can check in which Windows editions you want to add the drivers. To check that you can use the following PowerShell command:

Get-WindowsImage -ImagePath C:\Image\ISO\sources\install.wim
PowerShell Get-WindowsImage Windows Server 2019 Editions

PowerShell Get-WindowsImage Windows Server 2019 Editions

The Get-WindowsImage cmdlet will show you the different editions included in the 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 2019 Datacenter Core Edition. If you want to check which editions of Windows Server 2019 you should use, check out the Microsoft Docs.

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

Mount-WindowsImage

After the image is mounted you can now add the drivers to the Windows Server 2019 Image using the following command:

Add-WindowsDriver -Path C:\Image\Mount -Driver C:\Image\Drivers -Recurse
Add Drivers to Windows Server 2019 ISO Image

Add Drivers to Windows Server 2019 ISO Image

After you have added all the drivers to the image, you need to dismount the image and save it.

Dismount-WindowsImage -Path C:\Image\Mount -Save

We have now added the drivers to the Install image, and you should also add the drivers to your boot image if it is, for example, a network or storage controller driver you might need to install the server. To do this do the same steps to the C:\Image\ISO\sources\boot.wim.

Now you can use these WIM files with Windows Deployment services or create a USB drive to install Windows Server 2019. If you want to create an ISO file, you can use the oscdimg command-line tool. The oscdimg tool comes with the Windows Assessment and Deployment Kit (Windows ADK), which you can get here.

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

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



SVN Basic

subversionA colleague made a pretty cool blog post about svn basic on his blog. Subverion is a software versioning and a revision control system. At work all our program code and scripts, every little piece of code is going in your Subversion repository. This allows you to get back to earlier revisions of the code or simply share and work on code with other employees. Even your documentation is going into the Subversion repository.

On his blog post (German) he shows the basics of subversion, doing a checkout of e repository, adding files, changing files, removing files and more.

Here is a basic list of svn commands, if you need more information you should check the Subversion Homepage or try the Blog post from tspycher.com

svn checkout  http://svn.colab.company.com # SVN checkout
svn commit -m "My Message and Changes" # SVN committing changes and new files
svn add /files/*.* # Adding Files to the SVN Repository after this you have to commit that
svn update # Update your local copy

A lot of IDE’s (Integrated Development Environment) like Visual Studio or Xcode have SVN integrated.



iOS 4.1 beta 2 calendar invites

iOS 4.1 beta 2 with calendar invites

Apple just released iOS 4.1 beta 2. After some testing I found something I was looking for in every release. In iOS 4.1 beta 2 you can now send calendar invites to other people by creating a new event.



Powershell: Working with XML part 2

Powershell Header

After my first post (Powershell: Parsing XML part 1) about working with XML and Powershell, I have create this second post which describes how to create a XML file, Add content to the XML file, remove content from the XML file and save the XML objects as a file.

While I was writing a script which communicates with a webserver, I realized that I need some error handling if the server can not anwser a request from my script. For example if the webserver is down or has to much load.

I created a little retry part (Powershell: Simple retry logic) which retries several times. But if the Server is down for several hours or days your script hangs in a retry loop. Obviously this cant be the solution. After a little bit of thinking a decided to write the data, which I was trying to send, down in a XML file. And the next time the script runs it reads the XML file and tries to send the data again.

Thats the story behind my idea for saving data in a XML file.

Creating a XML object

<pre lang="xml">$FruitList = "&lt;Box&gt;
&lt;Fruit&gt;
&lt;Name&gt;Banana&lt;/Name&gt;
&lt;Color&gt;yellow&lt;/Color&gt;
&lt;/Fruit&gt;
&lt;/Box&gt;"

Save a XML object as a XML file

$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
</Box>

Open a saved XML file

<pre lang="xml">$FruitList = Get-Content ./myfruitlist.xml

Add data to XML object and save it in a XML file

# Copy Object from Banana
[Object]$CopyFruit = FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$NewFruit = $CopyFruit.Clone()
# Add Fruit to new Object
$NewFruit.Name = "Apple"
$NewFruit.Color = "green"
# Add Fruit to XML Object
$FruitList.Box.AppendChild($NewFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
	<Fruit>
		<Name>Apple</Name>
		<Color>green</Color>
	</Fruit>
</Box>

Change data from XML Object and save it as XML file

# Change Apple Color
$FruitList.Box.Fruit | Where-Object {$_.Name -eq "Apple"} | ForEach-Object { $_.Color = "red" }
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Banana</Name>
		<Color>yellow</Color>
	</Fruit>
	<Fruit>
		<Name>Apple</Name>
		<Color>red</Color>
	</Fruit>
</Box>

Remove data from XML Object and save it as XML file

# Remove Banana from Object
$RemoveFruit = $FruitList.Box.Fruit | Where-Object {$_.Name -eq "Banana"}
$FruitList.Box.RemoveChild($RemoveFruit)
#Save to XML object ot XML file
$FruitList.Save("./myfruitlist.xml")

XML:

<Box>
	<Fruit>
		<Name>Apple</Name>
		<Color>green</Color>
	</Fruit>
</Box>


Cheatsheet: Add roles and features to a Server Core installation #2

This are some commands to add roles and features to a Windows Server 2008 R2 Core installation.

You also can enable Remote MMC and Remote Server Manager to simply connect from a management server to the core server and add roles with GUI. This may only work within a domain environment. You can enable remote management pretty easy with the sconfig.cmd. Find out more about configuring Windows Server 2008 R2 Core installations here.

List available server roles and features:

oclist

Install, uninstall and configure Active Directory Domain Service role:

dcpromo

Help for dcpromo:

PS C:\> dcpromo /?

Command line parameters include:

/unattend[:filename]
Used to specify the unattend operation mode or supply an unattended install script file.

/adv
Enables advanced user options.

/uninstallBinaries
Used to uninstall Active Directory Domain Services binaries.

/?[:{Promotion | CreateDcAccount | UseExistingAccount | Demotion}]

/?:Promotion, /?:CreateDCAccount, /?:UseExistingAccount, and /?:Demotion
will display unattend parameters applicable to the specified task. /CreateDCAccount and /UseExistingAccount:Attach are mutually exclusive.

/CreateDCAccount
Creates an RODC account.

/UseExistingAccount:Attach
Attaches the server to an RODC account.

/forceRemoval
Forcefully uninstalls Active Directory Domain Services on this domain controller. The account for the domain controller will not be deleted in the directory, and changes that have occurred on this domain controller since it last replicated with a partner will be lost.

/?
Will display this help.

Unattend parameters can also be specified on the command-line. For example:

dcpromo.exe /ReplicaOrNewDomain:Replica

Press any key to quit ...

Install a role or feature its basically always the same:

start /w ocsetup <roleorfeature>

start /w ocsetup DNS-Server-Core-Role

Uninstall a role or feature:

start /w ocsetup <roleorfeature> /uninstall

start /w ocsetup DNS-Server-Core-Role /uninstall

Install SNMP feature:

start /w ocsetup SNMP-SC

Install Microsoft Hyper-v role:

start /w ocsetup Microsoft-Hyper-V