locked
Powershell script to install multiple *.cab file RRS feed

  • Question

  • Hello Gurus , 

    I am a beginner /noob in powershell and i have a requirement to write the powershell script to install windows updates by extracting the cab files  from msu . 

    1. Get the input from the user param ($sourcefilepath) 

    2. validate if filepath exist 

    3. If filepath exist , validate the file signature subject and extension 

    Got stuck here

    4 Script should validate all the files from  $sourcefilepath and verify its signature ( as microsoft )and extension as msu

    5 if the above condition is met (Point 4), then , copy the files to the $destinationfolder  

    6. Extract the  each msu and install it one by one with results.

    Can someone guide me here please ? 

    Thanks.. 


    Friday, January 24, 2020 4:02 PM

All replies

  • Please - when you crosspost the same question at the same time in different forums leave at least a hint that you did so and a link to the other forum post.

    https://powershell.org/forums/topic/powershell-script-to-install-multiple-cab-files/


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Friday, January 24, 2020 5:38 PM
  • There is never a need to do what you are asking.  The MSU and the system updater do all of this for you.  The technology is pretty much locked down by Microsoft as a security and reliability measure.  You should not try to undo this.  The only reason I can see for attempting to do this is to hack the files prior to installation.  That, also, won't work.  The technology prevents alteration of any system components.  Any professional hacker knows how to hack these installs which is why we don't download MSU files from sources other than Microsoft.

    If you need specific patches for some reason these are available from the Microsft Catalog and can be downloaded individually for those that can be installed independently.


    \_(ツ)_/

    Friday, January 24, 2020 6:14 PM
  • I should also note that MSI files are a different story and can be easily unpacked and verified with one command using the MSIExec program.  This is often used to set up administrative installs for products.

    MSI technology is a documented API that is available in the SDK.  

    WUSA use is documented here: https://support.microsoft.com/en-us/help/934307/description-of-the-windows-update-standalone-installer-in-windows

    WUSA allows extracting the cab and verifies them on extraction.  Read the docs for more background.

    Most of the questions you ask are already addressed by the WUSA utility.  Why you want to ignore this and do it externally with a script just doesn't make any sense.


    \_(ツ)_/

    Friday, January 24, 2020 6:20 PM
  • @jvr : Thanks for your reply . We have some restrictions on installing the package using wusa utility and dependency on *.cab thru dism .. so only ... 
    
    Here is the code :
    
    ---------------------
    
    Param($Sourcepath)
    
    if (!(Test-Path -path $Sourcepath ))
    {
    Write-Host "Required  files are missing in the file path"
                Exit(1)
    
    }
    
    
    
    $day = get-date -f dd-MM-yyyy-hh-mm-ss
    $patchdate = Get-Date -format "MM/dd/yyyy HH:mm:ss"
    $destinationFolder = "C:\Temp\OnDemand\$day"
    
    
    if (!(Test-Path -path $destinationFolder))
    {
          New-Item $destinationFolder -Type Directory
    }
    
    write-host "Destination folder created" -ForegroundColor Green
    
    
    ###### Before copying the files to destination , i want to to validate the files signature and it's extension at the source itself#######
    
    <<need help here >>> 
    
    Copy-Item -Path "$Sourcepath\*.*" -Destination $destinationFolder -Force     
    
    Write-Host "Files are copied to $destinationFolder" -ForegroundColor Green
    
    expand -f:* $destinationFolder\*.*  $destinationFolder
    
    write-host "Files expanded and extracted cab files" -ForegroundColor Green
    
    Remove-Item $destinationFolder\*.msu
    <<Need help here >>
    
    dism.exe /online /add-package /packagepath:$destinationfolder /quiet /norestart ##### Want to install *.cab files one by one rather than all at once 
    
    Remove-item $destinationFolder\*.*
    
    
    Get-HotFix |?{$_.InstalledOn -gt ((Get-Date).AddHours(-10))} | FT -AutoSize#
    
    
    write-host "Reboot may required to finish the installation"
    
    


    • Edited by xbee7z Saturday, January 25, 2020 11:16 AM
    Saturday, January 25, 2020 2:46 AM
  •    @ BOfH-666: 
    Thank you sir .. will follow the guidelines 
    • Edited by xbee7z Saturday, January 25, 2020 2:49 AM
    Saturday, January 25, 2020 2:48 AM
  • Please fix your post and format your code as code :  How to Use the Code Feature in a TechNet Forum Post.

    We have some restrictions on installing the package using wusa utility and dependency on *.cab thru dism .. so only ...

    ###### Before copying the files to destination , i want to to validate the files signature and it's extension at the source itself#######

    You try to substitute a proven, secure, reliable, industry common process with something self made. You should talk about the restrictions with the responsible department. Please do not re-invent the wheel. I doubt that you can come up with something better than microsoft. ;-) I assume you can use the time you'd save not doing something redundant/already existing in a much better way.


    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Saturday, January 25, 2020 11:04 AM
  • I  made it . Thanks :)
    Tuesday, January 28, 2020 1:26 AM