The function should be in your Deploy-Application.ps1 file, where you put the installation logic and other stuffs.
When you use the Mount-WIMFile a dismount task is automatically generated, you don’t need to worry about the dismount at all, but if you want it to be dismounted anyway you can uso the Dismoun-WIMFile with the objetct returned by the first function.
To create a WIM file use the New-WIMFile function (it uses $installName by default), like this:
The WIM file is created (by default) with the content of the Files folder, after that you can move the file anywhere, just include the path in the function:
I´m feeling really dumb as i don´t understand how to use the plugin. I have done everything in “AppDeployToolkitExtensions.ps1”
Should i after that put “New-WIMFile -Name $installName -SavetoPath (Join-Path -Path $dirSupportFiles -ChildPath “my_application_file.wim”)” in the Deploy-Application.ps1 file and where in that file in that case? And how should i run this from Deploy-Application.ps1?
It can be a bit hard the first time, the extension use should be (at least I planned this way) this:
Run Deploy-Application.ps1 with New-WIMFile function to create the compressed .wim file with the content of the Files folder (by default).
If everything went fine you should see the file in your Toolkit directory (by default).
The Files folder is not needed anymore (compressed in .wim file), can be deleted.
Comment or remove the New-WIMFile function in the script, we don’t want to compress again.
Add the Mount-WIMFile, will look for any .wim file and mount its content, by default mounted in the Files folder (can change this).
Add the Dismount-WIMFile at the end of the phase execution or in the catch if any unexpected error.
There is no correct way to use it, just keep in mind that to generate the .wim file you first need to have your “installation files” in a folder (Files by default) and run the package at least once to generate the .wim file.
Then the New-WIMFile function is not used (you’ve just created the .wim file), you have to mount and dismount the created file.
You will see a warning message if you forgot to remove the New-WIMFile function in the .ps1 file.
Check the documentation for the error exit codes, and the log for the mounting process.
In my opinion, maybe adding a “zero-config”-like condition to not have to comment out the wim file cmdlets each and every time. That way, you can just keep them in there with your template. I modified my Deploy-Application.ps1 script to reflect the following:
# Mount any WIM file found in script directory (last modified one if multiple)
# Zero-Config WIM Mounting
$global:WIMFileExists = $false
if ((Get-Item *.wim).count -ge 1) { $WIMFileExists = $true }
if ($WIMFileExists) { $MountedObject = Mount-WIMFile }
Then I just add if ($WIMFileExists) { in front of all the other WIM commands. That way, if you are dealing with small installations, you don’t have to remember to comment it out, and you can keep the template as just that, a template.
Doesn’t mean you need to add it, but just one less step you have to do.
Not a bad idea at all… The main problem is that you still have to execute at least one time the PS1 to create the .WIM file before publishing the APP in SCCM/Intune/MDM, so it can’t be fully zero-config… But, once the .WIM is created I can implement a way to avoid commenting the cmdlets… Thanks for the idea
Understood. That’s the tricky part. For me, I just import the module and run the command, or simply do a New-WindowsImage and then toss it in the folder.
I also made a mistake in my previous post. It seems even if there is a WIM, it would never mount. The relative path is always the main script, not the Deploy-Application.ps1 script. So you would need to edit line 4 to the following if ((Get-Item -Path $(Split-Path $invokingScript) -Filter *.wim).count -ge 1) {
Hi,
Has anyone been able to use a WIM file to install Autodesk products such as AutoCadLT or DWG TrueView?
I get an error when I’m trying to use a WIM file with these products.
Thanks