MSEndpointMgr / ConfigMgr

Microsoft Endpoint Configuration Manager scripts and tools
633 stars 281 forks source link

Oledlg.dll not found when within WinPE on a formatted Drive #133

Closed leebow55 closed 5 years ago

leebow55 commented 5 years ago

Hello, I have been using the BIOS Management scripts successfully for a while now, and adding the scripts into our OSD Task Sequence. The scripts are added whilst the device is still within WinPE and has not put the full OS onto the drive.

I had been getting the following error within the log - "Failed to copy DLL file. Abording update process"

This was because the section starting at Line #95 (check for required DLLs) cannot find the .DLL from any of the sources currently within the script. These are "OSDisk", and the paths for C:\Windows\System32\ and D:\Windows\System32. As the disk with the old running OS was formatted this file no longer exists.

My solution to this problem was to add the Oledlg.dll file to the source directory of the BIOS Scripts and add the following lines...

elseif ((Test-Path -Path $PSScriptRoot\OLEDLG.dll) -eq $true) { Copy-Item -Path "$PSScriptRoot\OLEDLG.dll" -Destination "$Path\OLEDLG.dll" Write-CMLogEntry -Value "Copying OLEDLG.dll from PSScriptRoot directory" -Severity 1 }

another option is that the WinPE Boot Media has the HTA optional Component installed and therefore that file is available at X:\Windows\System32

PS, there is a minor typo on Line #108 where Abording should be Aborting :)

Thank you

Wraith4260 commented 5 years ago

I am utilizing Modern BIOS Management in my environment before applying the OS so everything is running from X:\ . We also have WinPE-HTA enabled in our boot image and the script was still failing to locate it.

I was able to get around this by adding another elseif for the X:\ drive under the DLL check section like so:

# Check for required DLL's
if ((Test-Path -Path (Join-Path -Path $Path -ChildPath "OLEDLG.dll")) -eq $False) {
    Write-CMLogEntry -Value "Copying OLEDLG.dll to $Path directory" -Severity 1
    if (([string]::IsNullOrEmpty($TSEnvironment.Value("OSDisk"))) -eq $false) {
        Copy-Item -Path (Join-Path -path $TSEnvironment.Value("OSDisk") -ChildPath "Windows\System32\OLEDLG.dll") -Destination "$Path\OLEDLG.dll"
    }
    elseif ((Test-Path -Path C:\Windows\System32\OLEDLG.dll) -eq $true) {
        Copy-Item -Path "C:\Windows\System32\OLEDLG.dll" -Destination "$Path\OLEDLG.dll"
    }
    elseif ((Test-Path -Path D:\Windows\System32\OLEDLG.dll) -eq $true) {
        Copy-Item -Path "D:\Windows\System32\OLEDLG.dll" -Destination "$Path\OLEDLG.dll"
    }
    elseif ((Test-Path -Path X:\Windows\System32\OLEDLG.dll) -eq $true) {
        Copy-Item -Path "X:\Windows\System32\OLEDLG.dll" -Destination "$Path\OLEDLG.dll"
    }
    else {
        Write-CMLogEntry -Value "Failed to copy DLL file. Abording update process" -Severity 3; exit 1
    }
}
NickolajA commented 5 years ago

This has been added to version 1.0.7 of the script, thanks for sharing.

leebow55 commented 5 years ago

Thank you very much