PowerShell Scripting - Update Windows 10 USB install media  

Page 4 of 5 FirstFirst ... 2345 LastLast

  1. Posts : 32
    windows 100586.164
       #30

    flybynite said:
    You mean update the 1803 install.wim to 1809?
    Yup
      My Computer


  2. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #31

    avismile10 said:
    Microsoft just again released version 1809, i have an image with 1803, i want to know if there is a way for me to update the 1803 image to 1809.

    Thanks in advance.
    No, there isn't. Upgrading a deployment image or install media (ISO image) is not possible.
      My Computer


  3. Posts : 32
    windows 100586.164
       #32

    Kari said:
    No, there isn't. Upgrading a deployment image or install media (ISO image) is not possible.
    So how would you recommend having an image that stays always up to date with the latest windows versions?
      My Computer


  4. Posts : 4,802
    Windows 10 ProWorkstation -- Whichever is highest build number.
       #33

    avismile10 said:
    So how would you recommend having an image that stays always up to date with the latest windows versions?
    First of all I want to find out what you want to do. Do you mean a normal install image, or an image which has all your programs in it. I mean you can always make an iso for each Windows update, or even Insider Fast or Skip Ahead.
      My Computer


  5. Posts : 32
    windows 100586.164
       #34

    flybynite said:
    First of all I want to find out what you want to do. Do you mean a normal install image, or an image which has all your programs in it. I mean you can always make an iso for each Windows update, or even Insider Fast or Skip Ahead.
    I have an image with all my programs in it.

    I only started the image after 1803 so i never really had the issue, until now i prepared my image and them whatever update came out i just used DISM and added it to the wim file.
      My Computer


  6. Posts : 4,802
    Windows 10 ProWorkstation -- Whichever is highest build number.
       #35

    You could install that image in audit mode. Then update to newest version. Here is a nice tutorial. Create Windows 10 ISO image from Existing Installation | Tutorials
      My Computer


  7. Posts : 5
    Windows 10 Pro 1809
       #36

    Using this script to integrate INF drivers


    Kari -

    This is the section where you originally had the updates being integrated. As you said in the script, we were free to edit. This is where I edited it to integrate INF drivers for the chosen corresponding image :

    #########################################################
    # Inject drivers
    #########################################################

    $VMWare = "<folder path>"
    $TR4 = "<folder path>"


    dism /Image:Q:\Mount /Add-Driver /driver:$VMWare /recurse /forceunsigned
    dism /Image:Q:\Mount /Add-Driver /driver:$TR4 /recurse /forceunsigned

    Write-Host "Drivers injected"

    dism /Image:Q:\Mount /Get-Drivers | Out-File C:\ImageDrivers.txt

    Both lines do integrate drivers, although the 2nd for some reason, does produce errors (not sure why). I have all needed *.cat, *.sys, *.dll and *.inf in each folder. The Add-Windows Driver cmdlet for some reason errored out. I've uploaded the edited script. Also using the ForEach($File in $DriverFolder), produced an endless loop in the script. Here was the output when using ForEach($File in $DriverFolder): Any ideas on how to fix? Could it be the recurse option?

    Deployment Image Servicing and Management tool
    Version: 10.0.17763.1

    Image Version: 10.0.18362.175

    Searching for driver packages to install...
    Found 3 driver package(s) to install.
    Installing 1 of 3 - oem0.inf: The driver package was successfully installed.
    Installing 2 of 3 - oem1.inf: The driver package was successfully installed.
    Installing 3 of 3 - oem2.inf: The driver package was successfully installed.
    The operation completed successfully.

    Deployment Image Servicing and Management tool
    Version: 10.0.17763.1

    Image Version: 10.0.18362.175

    Searching for driver packages to install...
    Found 3 driver package(s) to install.
    Installing 1 of 3 - oem0.inf: The driver package was successfully installed.
    Installing 2 of 3 - oem1.inf: The driver package was successfully installed.
    Installing 3 of 3 - oem2.inf: The driver package was successfully installed.
    The operation completed successfully.
      My Computer


  8. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #37

    bc113 said:
    I've uploaded the edited script.
    Can't see any script in your post. Please upload and post it.

    Kari
      My Computer


  9. Posts : 5
    Windows 10 Pro 1809
       #38

    TestDrivers.rar

    I attached the script, however, here is the whole thing:

    Code:
    ########################################################## 
    # 
    # USBUpdate.ps1
    #
    # A PS Script to update Windows 10 install USB. 
    # 
    # You are free to edit & share this script as long as
    # source TenForums.com is mentioned.
    #
    # *** Twitter.com/TenForums *** Facebook.com/TenForums ***
    # 
    # Script by Kari 
    # - TenForums.com/members/kari.html
    # - Twitter.com/KariTheFinn
    # - YouTube.com/KariTheFinn
    #
    # 'Use-RunAs' function to check if script was launched
    # in normal user mode and elevating it if necessary by
    # Matt Painter (Microsoft TechNet Script Center)
    # https://gallery.technet.microsoft.com/scriptcenter/ 
    #
    ##########################################################
    
    ##########################################################
    # Checking if PS is running elevated. If not, elevating it
    ##########################################################  
    
    function Use-RunAs 
    {    
        # Check if script is running as Administrator and if not elevate it
        # Use Check Switch to check if admin 
         
        param([Switch]$Check) 
         
        $IsAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()` 
            ).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator") 
             
        if ($Check) { return $IsAdmin }   
          
        if ($MyInvocation.ScriptName -ne "") 
        {  
            if (-not $IsAdmin)  
              {  
                try 
                {  
                    $arg = "-file `"$($MyInvocation.ScriptName)`"" 
                    Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'  
                } 
                catch 
                { 
                    Write-Warning "Error - Failed to restart script elevated"  
                    break               
                } 
                exit 
            }  
        }  
    } 
    
    Use-RunAs 
    
    ##########################################################
    # Show short instructions to user
    ##########################################################   
    
    cls
    Write-Host                                                                       
    Write-Host ' This script will update Windows 10 install media with new drivers'
    Write-Host ' downloaded from http://www.catalog.update.microsoft.com'
    Write-Host 
    Write-Host ' Please notice that the process will take quite some time, depending'
    Write-Host ' on amount and size of drivers being applied to Windows image. '
    Write-Host
    Write-Host ' If you already have a bootable Windows 10 install media on USB '
    Write-Host ' flash drive, plug it in now.'
    Write-Host 
    Write-Host ' If you want to upgrade an ISO instead, mount (double click) a Windows'
    Write-Host ' ISO image and copy its content to a folder on local PC, for instance'
    Write-Host ' "D:\ISO_Files". Make sure the folder has no other content.'
    Write-Host 
    Write-Host ' When ISO files have been copied to a hard disk folder, or USB drive'
    Write-Host ' has been plugged in, press Enter to start.'
    Write-Host 
    Write-Host '                                                                      ' -ForegroundColor DarkBlue -BackgroundColor White
    Write-Host ' Notice that you cannot use this script to update an ESD based install' -ForegroundColor DarkBlue -BackgroundColor White
    Write-Host ' media like for instance ISO / USB made with Media Creation Tool.     ' -ForegroundColor DarkBlue -BackgroundColor White
    Write-Host ' You must first convert "install.esd" file to "install.wim". See      ' -ForegroundColor DarkBlue -BackgroundColor White
    Write-Host ' TenForums tutorial "Convert ESD to WIM":' -ForegroundColor DarkBlue -BackgroundColor White -NoNewline
    Write-Host ' http://w10g.eu/esd2wim      ' -ForegroundColor DarkCyan -BackgroundColor White
    Write-Host '                                                                      ' -ForegroundColor DarkBlue -BackgroundColor White
    Write-Host
    Write-Host ' ' -NoNewline
    pause
    
    ##########################################################
    # Delete possible old log files from previous runs
    ##########################################################
    
    if (Test-Path C:\DriverSuccess.log) {Remove-Item C:\DriverSuccess.log}
    if (Test-Path C:\DriverFail.log) {Remove-Item C:\DriverFail.log}
    
    ##########################################################
    # Prompt user for path to install media (USB drive) or 
    # folder where ISO content was copied to.
    #
    # Using 'while' loop to check that source given by user 
    # contains a Windows image, if not user is asked to chek
    # path and try again
    ##########################################################
    
    $WimCount = 0
    while ($WimCount -eq 0) {
    cls
    Write-Host 
    Write-Host ' Enter source path. In case you are using a plugged in USB flash'
    Write-Host ' drive, simply enter its drive letter followed by : (colon).'
    Write-Host
    Write-Host ' If the source you are using is a Windows 10 ISO or DVD, enter.'
    Write-Host ' path to folder where you copied ISO / DVD content.'
    Write-Host 
    Write-Host ' Notice please: If your source contains both 32 (x86) and 64 (x64)'
    Write-Host ' bit versions, add \x86 or \x64 to source depending on which'
    Write-Host ' bit version you want to update.'
    Write-Host 
    Write-Host ' Examples:'
    Write-Host ' - A USB drive, enter its drive letter with colon (D: or F:)'
    Write-Host ' - A USB drive with both bit versions, enter D:\x86 or D:\x64'
    Write-Host ' - ISO files copied to folder, enter path (D:\ISO_Files)'
    Write-Host ' - Dual bit version ISO copied to folder, enter path with bit version'
    Write-Host '   (W:\MyISOFolder\x86 or W:\MyISOFolder\x64)' 
    Write-Host
    
    $ISOFolder = Read-Host -Prompt ' Enter source, press Enter'
    $WimFolder = $ISOFolder
       
        if (Test-Path $WimFolder\Sources\install.wim)
            {
            $WimCount = 1
                if (($WIMFolder -match "x86") -or ($WIMFolder -match "x64"))
                {
                $ISOFolder = $ISOFolder -replace "....$" 
                }
            }
        elseif (Test-Path $WimFolder)
            {
            $WimCount = 0
            cls
            Write-Host
            Write-Host ' No Windows image (install.wim file) found'
            Write-Host ' Please check path and try again.'
            Write-Host
            Pause
            }
        else
            {
            $FileCount = 0
            cls
            Write-Host
            Write-Host ' Path'$ISOFolder 'does not exist.'
            Write-Host
            Write-Host ' ' -NoNewline
            Pause
            }
        }
    
    $WimFile = Join-Path $WimFolder '\Sources\install.wim'
    
    ##########################################################
    # List Windows editions on image, prompt user for
    # edition to be updated
    ##########################################################
    
    cls
    Get-WindowsImage -ImagePath $WimFile | Format-Table ImageIndex, ImageName
    Write-Host 
    Write-Host ' The install.wim file contains above listed Windows editions.'
    Write-Host ' Which edition should be updated?'
    Write-Host  
    Write-Host ' Enter the ImageIndex number of correct edition and press Enter.'
    Write-Host ' If this is a single edition Windows image, enter 1.'                                                                     
    Write-Host
    $Index = Read-Host -Prompt ' Select edition'
    
    ##########################################################
    # Prompt user for folder containing downloaded WU files
    # (*.cab and / or *.msu). Again, a 'while' loop is used to
    # check folder contains Windows Update files, if not user
    # is asked to check path and try again
    ##########################################################
    
    $FileCount = 0
    while ($FileCount -eq 0) {
    cls
    Write-Host 
    Write-Host '  Enter path to folder containing driver'
    Write-Host '  *.inf files.'
    Write-Host 
    Write-Host '  Be sure to enter correct path / folder!'
    Write-Host                                                                       
    
    $DriverFolder = Read-Host -Prompt ' Path to folder containing driver files'
    
    if (Test-Path $DriverFolder)
        {
        $FileCount = (Get-ChildItem $DriverFolder\* -Include *.inf).Count
        if ($FileCount -eq 0)
            {
            Write-Host
            Write-Host ' No driver files found in given folder.' 
            Write-Host ' Check the path and try again.'
            Write-Host
            Write-Host ' ' -NoNewline
            pause
            }
        }
        else
            {
            $FileCount = 0
            cls
            Write-Host
            Write-Host ' Path'$DriverFolder 'does not exist.'
            Write-Host
            Write-Host ' ' -NoNewline
            Pause
            }
      }
    
      ##########################################################
    # Ask user which drive should be used for temporary 
    # working folder 'Mount'. If 'Mount' exists on selected
    # drive, delete and recreate it.
    ##########################################################
    
    cls
    Write-Host
    [System.IO.DriveInfo]::GetDrives() | Where-Object {$_.DriveType -eq 'Fixed'} | Format-Table @{n='Drive ID';e={($_.Name)}}, @{n='Label';e={($_.VolumeLabel)}}, @{n='Free (GB)';e={[int]($_.AvailableFreeSpace/1GB)}}
    Write-Host
    Write-Host ' Above is a list of all hard disk partitions showing available'
    Write-Host ' free space on each of them. Select a partition for temporary'
    Write-Host ' folder to mount Windows image. Selected partition must have at'
    Write-Host ' least 15 GB available free space. Folder will be removed when'
    Write-Host ' image has been updated.'
    Write-Host
    $Drive = Read-Host -Prompt ' Enter drive letter and press Enter'
    $Mount = $Drive.SubString(0,1) + ':\Mount'
    
    if (Test-Path $Mount) {Remove-Item $Mount}
    $Mount = New-Item -ItemType Directory -Path $Mount
    
    ##########################################################
    # Mount Windows image in temporary mount folder.
    #
    # Adding eight empty lines to $EmptySpace variable to be
    # used as placeholder to push output below PowerShell
    # progressbar which is shown on top. Five empty lines would
    # be enough for PowerShell ISE but standard PowerShell will
    # need eight lines, otherwise output remains hidden
    ##########################################################
    
    cls
    $EmptySpace = @"
    
    
    
      
     
    
    
    
    "@
    
    Write-Host $EmptySpace
    Write-Host ' Mounting Windows image. This will take a few minutes.'
    Mount-WindowsImage -ImagePath $WimFolder\Sources\install.wim -Index $Index -Path $Mount | Out-Null
    Write-Host
    Write-Host ' Image mounted, applying drivers.'
    Write-Host
    
    #########################################################
    # Inject drivers
    #########################################################
    
    $VMWare = "<folder>"
    $TR4 = "<folder>"
    
    
    dism /Image:Q:\Mount /Add-Driver /driver:$VMWare /recurse /forceunsigned
    dism /Image:Q:\Mount /Add-Driver /driver:$TR4 /recurse /forceunsigned 
    
    Write-Host "Drivers injected" 
    
    dism /Image:Q:\Mount /Get-Drivers | Out-File C:\ImageDrivers.txt 
    
    ##########################################################
    # Dismount Windows image saving updated install.wim. Using
    # $EmptySpace variable again to push output from under
    # PowerShell progressbar to visible area under it
    ##########################################################
    
    cls
    Write-Host $EmptySpace
    Write-Host ' Dismounting Windows image, saving updated install.wim.'
    Write-Host ' This will take a minute or two.'
    Dismount-WindowsImage -Path $Mount -Save | Out-Null
    cls
    Last edited by Brink; 08 Jul 2019 at 13:11. Reason: code box
      My Computer


  10. Posts : 17,661
    Windows 10 Pro
    Thread Starter
       #39

    bc113 said:
    I attached the script.
    Fixing one obvious syntax error and one peculiarity in your script, it worked perfectly. In screenshot I am injecting my laptop's OEM drivers to mounted offline image:
    PowerShell Scripting - Update Windows 10 USB install media-script-ok.jpg

    The syntax error:
    PowerShell Scripting - Update Windows 10 USB install media-op-script.jpg

    Highlighted part corrected:
    PowerShell Scripting - Update Windows 10 USB install media-corrected-script.jpg

    And the peculiarity:
    PowerShell Scripting - Update Windows 10 USB install media-op-script-2.jpg

    No reason to use another variable when you have already read path to folder containing drivers to variable $DriverFolder:
    PowerShell Scripting - Update Windows 10 USB install media-corrected-script-2.jpg

    Kari
      My Computer


 

Tutorial Categories

PowerShell Scripting - Update Windows 10 USB install media Tutorial Index Network & Sharing Instalation and Upgrade Browsers and Email General Tips Gaming Customization Apps and Features Virtualization BSOD System Security User Accounts Hardware and Drivers Updates and Activation Backup and Restore Performance and Maintenance Mixed Reality Phone


  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 23:19.
Find Us




Windows 10 Forums