5 Replies Latest reply on Feb 21, 2018 9:16 AM by Silvercoupe

    How do you use dism.exe in the Deploy Image action?

    Apprentice

      I would like to use dism.exe to restore images using OS provisioning since ImageX has been deprecated since Windows 8 but I have not found instructions for how to do it.

       

      This is what I have tried so far, with varying results.

      1. Use an "Execute file" action to launch dism.exe and specify the appropriate parameters.  E.g. /Apply-Image /ImageFile:"\\<servername>\<path_to_Image>\win10x641709base.wim" /Index:1 /ApplyDir:C:\ .  This launches a new command prompt window and restores the image using dism.exe, however we do get visual feedback in neither the command prompt window nor the provisioning window until the task has completed.  The behavior is the same whether we capture output or not.
      2. I created a new "Deploy image" action, and chose "Other".  I specified the \\<servername>\<path_to_Image>\win10x641709base.wim for the image name.  The task currently downloads dism.exe files from the server and runs that, so I set imaging tool path to C:\Misc\Pre-OS_Installation\GetDISM\dism.exe .  For command line parameters I specified /Apply-Image /ImageFile:"\\<servername>\<path_to_Image>\win10x641709base.wim" /Index:1 /ApplyDir:C:\ .  It restores the image but it neither launches a command prompt window nor provides any output in the provisioning window while it is restoring the image.

       

      So, I have two questions:

      1. How do you force provisioning template actions to display in real-time output rather than waiting until the action has completed?
      2. Is there a recommended way to use DISM as the method for restoring an image, and if so, is there a way to make it display in real-time the progress of the restore?
        • 1. Re: How do you use dism.exe in the Deploy Image action?
          Sebastien.Felix SupportEmployee

          I don't think dism offers an easy way to provide a progress bar as ImageX can do. It may require a function to read the output file and show it then, but nothing easy. I might be wrong.

          Maybe it won't suit your purpose, but why don't you try to use the "LANDESK ImageW V2" (From Teradata actually) we provide to capture & deploy the images? It will provide a full screen with the progress bar.

          If you really need to use dism for whatever reasons and then show a progress bar, you will need to create an Enhancement Request on our platform, but it may be available in future versions, not in the short term.

          • 2. Re: How do you use dism.exe in the Deploy Image action?
            Apprentice

            Thank you for the feedback.  I figured out a workaround that allows us to use DISM and shows a progress indicator, though it does not give real-time updates on estimated time remaining but it is better than no feedback at all.

             

            First, we had to add the required DISM Powershell modules to the Ivanti OS provisioning boot images.  I had already installed the Windows 10 "Assessment and Deployment Kit" on my workstation.  I used UltraISO to extract the boot.wim and boot_x64.wim from the provisioning ISO's Boot directory into my C:\Misc\PE folder.  I created the mount point folders C:\Misc\PE\x86 and C:\Misc\PE\x64.  Then I ran the following commands to mount each .wim file, install the necessary Powershell modules, and then commit those changes.:

             

            Dism /Mount-Image /ImageFile:"C:\misc\pe\boot_x86.wim" /Index:1 /MountDir:"C:\Misc\PE\x86"
            Dism /Add-Package /Image:"C:\Misc\PE\x86" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-WMI.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x86" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-NetFx.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x86" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-Scripting.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x86" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-PowerShell.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x86" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\x86\WinPE_OCs\WinPE-DismCmdlets.cab"
            Dism /Unmount-Image /MountDir:"C:\Misc\PE\x86" /Commit
            
            Dism /Mount-Image /ImageFile:"C:\misc\pe\boot_x64.wim" /Index:1 /MountDir:"C:\Misc\PE\x64"
            Dism /Add-Package /Image:"C:\Misc\PE\x64" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-WMI.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x64" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-NetFx.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x64" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-Scripting.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x64" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-PowerShell.cab"
            Dism /Add-Package /Image:"C:\Misc\PE\x64" /PackagePath:"C:\Program Files (x86)\Windows Kits\10\Assessment and Deployment Kit\Windows Preinstallation Environment\amd64\WinPE_OCs\WinPE-DismCmdlets.cab"
            Dism /Unmount-Image /MountDir:"C:\Misc\PE\x64" /Commit
            

             

            Then I replaced the existing boot.wim and boot_x64.wim files in the os provisioning .ISO with the modified .wim files.

             

            In my provisioning template's "OS Installation" section I created a "Map to Preferred Server"  action called "Map drive to preferred server".  I mapped P: to our Packages folder on our server.

             

            Right below that action I created an "Execute File" action with the following settings:

            • Target path and filename: X:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
            • Command-line parameters: -executionpolicy bypass -nologo -noprofile -file "P:\Provisioning\OS_Installation\RestoreImage\win10x641709base.ps1"
            • Expected return value: = 0
            • Stop processing the template if action fails: True

             

            I created a Powershell script called "P:\Provisioning\OS_Installation\RestoreImage\win10x641709base.ps1" with the following in it:

            Import-Module dism
            
            $StartTime = Get-Date
            write-host "StartTime = $StartTime"
            Expand-WindowsImage -ApplyPath C:\ -ImagePath "P:\images\win10x641709base.wim" -Index 1
            $EndTime = Get-Date
            write-host "EndTime = $EndTime"
            $Duration = NEW-TIMESPAN –Start $StartTime –End $EndTime
            write-host "Duration = $Duration"
            

             

            This way we are now able to use DISM - Microsoft's recommended method for capturing and restoring Windows images - with a progress indicator in Ivanti's OS provisioning environment.

            dism.png

            1 of 1 people found this helpful
            • 3. Re: How do you use dism.exe in the Deploy Image action?
              Silvercoupe Apprentice

              This looks great, thanks for the info.  Have you tried leveraging self-organizing multicast to deploy your image with this?  I'm thinking this would not work for that as you're hard coding a path to your WIM file.  The Multicast in WinPE will create a temp partition to download the WIM file that may be a different drive letter on each machine (depending on if it had a DVD/card reader, or maybe that's been fixed with 2017.3 SU2.).  Just curious.

              • 4. Re: How do you use dism.exe in the Deploy Image action?
                Apprentice

                We are just beginning to use Ivanti OS provisioning, so we have not looked into the multicast option yet.  Depending on how it works, I guess there is the possibility that you could pass the path in as a parameter to the Powershell script if it is able to determine a source address programmatically.

                • 5. Re: How do you use dism.exe in the Deploy Image action?
                  Silvercoupe Apprentice

                  We have been using ImageW (native LANDESK imaging tool) for years.  We are migrating about 20000 devices to Windows 10 this summer and will be using DISM.  DISM allows more flexibility to deploy to both BIOS and UEFI configured devices with the same image/templates.  The multicast option is nice for mass deployments.  We are having trouble using DISM with the multicast option, but IMAGEX works just fine and is a native option when creating provisioning templates.  It would be nice to see DISM as a native option in the future.  I know there are one or two other posts for the same topic as well.