Automating MEMCM install part 1 – ISO expansion

As part of a Microsoft Endpoint Manager Configuration Manager (MEMCM) after the CD / DVD ISO is downloaded from the Licensing site or Demo site the ISO needs to be expanded and the prerequisites need to be downloaded.

Instead of manually mounting the ISO and copying the contents from the mounted drive, then executing the commands to download the prerequisites. I have prepared a PowerShell script to automate those functions. Simply place the PowerShell script in a folder with just the ISO, and then execute the PowerShell.

## Get current directory
$sCurDir= "$($(get-location).Path)"

#if only one ISO in folder
if ((Get-ChildItem -path "$($sCurDir)" -filter *.iso| Measure-Object).Count -eq 1)
    #Get ISO file
    $file = Get-ChildItem -path "$($sCurDir)" -filter *.iso

    #make sure iso is unblocked. 
    Get-ChildItem -Path "$($file)" | Unblock-File

    #mount ISO file
    Mount-DiskImage -ImagePath "$($file.FullName)" -PassThru

    $ImageDrive = (Get-DiskImage -ImagePath "$($file.FullName)"| Get-Volume).DriveLetter
    Copy-Item -Path "$($ImageDrive):\*" -Destination "$($sCurDir)\" -Recurse -Force

    #unmount ISO file
    Dismount-DiskImage -ImagePath "$($file.FullName)" #-PassThru


if (Test-path "$($sCurDir)\SMSSETUP\BIN\X64\setupdl.exe")
    . "$($sCurDir)\SMSSETUP\BIN\X64\setupdl.exe" "$($sCurDir)\prereq" 


Leave a Reply