# OSDWindowsImage

#### There aren't many days that I don't mount a WIM file ... which is where these two functions will become my primary tools

{% hint style="warning" %}
**Before you start playing around with this, make sure you update the OSD Module to 19.11.22 or newer and that you have the OSDSUS Module installed and updated ...**
{% endhint %}

## Functions

{% content-ref url="broken-reference" %}
[Broken link](https://osd.osdeploy.com/docs/broken-reference)
{% endcontent-ref %}

{% content-ref url="broken-reference" %}
[Broken link](https://osd.osdeploy.com/docs/broken-reference)
{% endcontent-ref %}

## Mount-WindowsImage

#### Mount-OSDWindowsImage is based off of Mount-WindowsImage.  So why the need for a new function?  Here's a few reasons

* **I can't just specify a WIM**
* **I have to specify an Index**
* **My Path (Mount Directory) needs to exist**

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGiVlNaxqz0oNO7bEN%2F-LuGjH_vt4PbMCh2Y0Li%2Fimage.png?alt=media\&token=600b25ab-95ab-4f2b-b58c-ba406750beb0)

## Mount-OSDWindowsImage

For starters, all you need to provide is a WIM (Position 0).  There is no need to specify an Index as Index 1 is assumed if one is not provided.

### Mount WIM

The WIM is mounted to a Random directory in $env:TEMP.  This directory is automatically created

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGiVlNaxqz0oNO7bEN%2F-LuGkNxJFsdHoO-NVaK8%2Fimage.png?alt=media\&token=d890b18d-57b4-4c0f-baa9-2567c3c05a7c)

### Mount and Explore

And finally, the Explorer parameter will automatically open Windows Explorer to the Mount Path

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGiVlNaxqz0oNO7bEN%2F-LuGm0H3hepKjFFAPCX5%2Fimage.png?alt=media\&token=27c6a1d3-5091-4562-96c5-2c2c8882d6ee)

## Update-OSDWindowsImage

#### Finally this is the gem for those of you that [Hate OSDBuilder](https://www.osdeploy.com/blog/2019-11/i-hate-osdbuilder).  You will need an up to date [OSDSUS](http://osdsus.osdeploy.com) for this to work properly

### Windows Image Mount Path Is Optional

Yes Boys and Girls, this is quite a treat.  Simply run the function without any Parameters.  If you have a Mounted Windows Image, it will find it ... and let you know if it needs any updates

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGnW0ZJTn-cE7yq1jh%2F-LuH0iW7W5lGe9KeBrgQ%2Fimage.png?alt=media\&token=ac77ed57-913e-4fb8-b617-826a603f1be4)

### Multiple Windows Images - Mounted

Ok, did I just mount three WIMS in a single command line?  Ok, now I'm just showing off ... but as you can see, `Update-OSDWindowsImage` will find all three and give me an update

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGnW0ZJTn-cE7yq1jh%2F-LuH1ysTIgd4PdAGMCaz%2Fimage.png?alt=media\&token=ba61f10d-432c-4a3c-a9b5-0f340151bd1c)

### Multiple Windows Images - Mount | Update | Dismount

If you thought that was it ... yes you can use this in the Pipeline

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuGnW0ZJTn-cE7yq1jh%2F-LuH2yktPojbPo1tuzRC%2Fimage.png?alt=media\&token=652e4435-4123-4010-84d1-d4c6e87232cf)

### Install Updates

#### OK, I think you get the idea of the different ways you can use it ... so let's focus on the Updates.  You can use these Update values

* **Check (Default)**
* **All**
* **SSU**
* **LCU**
* **DotNet**
* **DotNetCU**

#### And there's even a BitsTransfer parameter too!

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuH3OoEj9oklwqAeqAf%2F-LuH6NbX-0DdqtaPxq1_%2Fimage.png?alt=media\&token=cf9f61fc-c73d-44a3-af4b-8045f6ec554a)

### One-Liner

#### So here is your PowerShell One-Liner to Mount, Identify the OS, Identify the Required Updates, Download the Updates, Apply the Updates, and finally, Dismount and Save an Install.wim.  This by far makes the shortest WIM Update script ever.  Enjoy!

```
Mount-OSDWindowsImage T:\WimOS\install.wim | Update-OSDWindowsImage -Update All | Dismount-WindowsImage -Save
```

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuH7Yk43VW1Z6o9tQe2%2F-LuH9pSjprDBtWbnpUpa%2Fimage.png?alt=media\&token=72d7c305-59de-4d75-8f41-417ff5786672)

#### Or you can Script the solution for better readability

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuJfPl06MMWILU-jQq1%2F-LuJfUf70YMDGUobuCsy%2Fimage.png?alt=media\&token=5c0acbaa-4da1-461f-a9eb-9e70d1bc2042)

### Downloads and Logs

#### If you need the Downloads and Logs (you know how I am about Log files), simply look in $env:TEMP\OSD

![](https://3420392058-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LpnxLqvh8u2fEz86kIM%2F-LuH9sQUhF5HeM7Vwbtd%2F-LuHAiJ-jQfQJHoWHRWv%2Fimage.png?alt=media\&token=0b92e701-be87-4232-a8a0-4102fcf52268)

## OSD Helper Functions

#### Finally some other functions from the OSD Module were used to make this all work

### Identify the Mounted OS Information

{% content-ref url="trash/general/get-regcurrentversion" %}
[get-regcurrentversion](https://osd.osdeploy.com/docs/trash/general/get-regcurrentversion)
{% endcontent-ref %}

### Identify the Installed Updates

{% content-ref url="trash/general/get-osdsessions" %}
[get-osdsessions](https://osd.osdeploy.com/docs/trash/general/get-osdsessions)
{% endcontent-ref %}

### Download the Updates

{% content-ref url="trash/general/save-osddownload" %}
[save-osddownload](https://osd.osdeploy.com/docs/trash/general/save-osddownload)
{% endcontent-ref %}
