Jump to content


anyweb

How can I set video resolution dynamically during UEFI network boot in System Center 2012 R2 Configuration Manager ?

Recommended Posts

Introduction

In a previous post I showed you how you can change the video resolution while in WinPE to fix resolution issues on Lenovo hardware when using UEFI network boot. As there is more and more hardware capable of using UEFI mode the next logical step was to make this more dynamic without having the need to update packages to distribution points. This issue will only affect you if you are displaying HTA's while still in WinPE (Hyper Text Applications such as this one) and if those HTA's are bigger than the screen resolution that WinPE defaults to in UEFI mode. This problem may occur on more manufacturers than Lenovo and if i see it occuring on other manufacturers i'll change the script accordingly to deal with them, but for now, it's Lenovo only.

 

Note: The issue that this resolves only occurs in UEFI network boot scenarios, the same hardware, same task sequence, same boot image will not show the same behaviour for USB boot.

 

Solution

The solution is a couple of PowerShell scripts I wrote, one of which detects the Lenovo model, and based on that searches for a folder matching the model name (eg: ThinkPad X230) in a predefined network location and if it exists uses drvload to load the inf file in the root of that folder. This means that you do not have to create any package containing the video drivers, and you only need to copy the video drivers for affected models to the pre-defined location.

 

To implement the solution, follow the steps below:

 

Step 1. Create some folders and a share

On a server of your choice, create a share called hidden$. Create a bunch of subfolders in the format VideoDrivers\Lenovo <Model> where model is the model name, eg: ThinkPad X230, you should create one folder for each Lenovo model you support for UEFI deployments. The following PowerShell will do that for you just change the DataDrive variable and run the script with Administrator credentials. If you already have a share called hidden$ you can run this script anyway to create the folders.

#
# creates some folders for the UEFI Video fix and shares the hidden folder as hidden$
# specify the drive letter that you want the folders created on using $DataDrive
# niall brady 2015/4/27
#
$DataDrive = "D:"
# create some folders
# create array of folders to create
     $strfolders = @("Hidden", "Hidden\VideoDrivers", "Hidden\VideoDrivers\ThinkPad X1", "Hidden\VideoDrivers\ThinkPad 10" ,"Hidden\VideoDrivers\ThinkPad Yoga", "Hidden\VideoDrivers\ThinkPad Helix" ,"Hidden\VideoDrivers\ThinkPad T420" ,"Hidden\VideoDrivers\ThinkPad T430" ,"Hidden\VideoDrivers\ThinkPad T440" ,"Hidden\VideoDrivers\ThinkPad T450" ,"Hidden\VideoDrivers\ThinkPad W520" ,"Hidden\VideoDrivers\ThinkPad W530" , "Hidden\VideoDrivers\ThinkPad W540","Hidden\VideoDrivers\ThinkPad X220","Hidden\VideoDrivers\ThinkPad X230","Hidden\VideoDrivers\ThinkPad X240","Hidden\VideoDrivers\ThinkPad X250")
foreach ($objItem in $strfolders) {

if (Test-Path $DataDrive\$objItem){
    write-host "$DataDrive\$objItem exists, skipping."
    }
    Else
    {
    write-host "$DataDrive\$objItem doesn't exist, creating folder."
    New-Item $DataDrive\$objItem -ItemType Directory | out-null
    }  
     }

# create a share
write-host "sharing $DataDrive\hidden as hidden$ ."
New-SmbShare –Name Hidden$ –Path $DataDrive\Hidden -FullAccess EVERYONE -ErrorAction SilentlyContinue
write-host "All done !"

PowerShell to create folders.png

 

After the script is done running, you can review the folder structure it has created

 

folder structure is created.png

 

Step 2. Populate the folders with video drivers for each model

Using Lenovo's support.lenovo.com website, search for a model and select the Component called Display and Video Graphics and then download the Windows 8.1 video drivers for each model you intend to support.

 

lenovo model driver.png

 

The extracted files (for Lenovo ThinkPad X230 are shown below)

 

x230 video drivers.png

 

However this is not what we need, do NOT simply copy/paste the drivers directly from the video drivers download. We need the actual driver usually located in the Graphics folder as shown below

 

inf file in video graphics sub folder.png

 

Copy that folder and all files/folders within to the corresponding model folder in the hidden folder structure

 

drivers copied to destination.png

 

Repeat the above process for any models you wish to support using this method, remove any folder names that don't contain any drivers.

 

Step 3. Download the script

The PowerShell script to dynamically install the video driver is available here PowerShell.zip.

 

Extract the script to the hidden$ share root as shown below.

 

powershell script extracted to hidden share.png

 

Step 4. Edit the Task sequence

In the ConfigMgr console, in Software Library, Operating Systems, Task Sequences, right click and edit a previously created Deploy task sequence and add the following New Group, called Dynamic UEFI Video fix, by clicking on the Add drop down menu and selecting New Group. Make sure the New Group occurs before displaying any HTA.

 

New Group.png

 

In the New Group, click on the Options tab and add the following options:

 

* If All the conditions are true

* WQL Query:

Select * FROM Win32_ComputerSystem WHERE Model Like "3701%"
or model like "3702%"
or Model Like "20C3%"
or Model Like "20C0%"
or Model Like "20cg%"
or Model Like "20ch%"
or Model Like "20BS%"
or Model Like "20BT%"
or Model Like "2344%"
or Model Like "2349%"
or model like "2356%"
or Model Like "20B7%"
or Model Like "20AW%"
or Model Like "4236%"
or Model Like "4177%"
or Model Like "2344%"
or Model Like "2349%"
or model like "2356%"
or Model Like "20B7%"
or Model Like "20AW%"
or Model Like "4282%"
or Model like "4284%"
or Model Like "4282%"
or Model like "4284%"
or Model Like "20BH%"
or Model Like "4291%"
or Model like "4299%"
or Model Like "20AM%"
or model like "20AL%"
or Model Like "20CL%"
or Model Like "20BU%"
or Model Like "2325%"
or Model Like "2447%"

* Task Sequence Variable: _SMSTSBootUEFI Equals True

 

* Task Sequence Variable: _SMSTSLaunchMode Equals PXE

 

as per the screenshot below

 

options tab.png

 

Next, click on the Add drop down again, select General, then select Run Command Line, the step uses the following settings:

 

Name: remove any existing network connections

Command Line: cmd.exe /c "net use * /del /yes"

 

Again, click on the Add drop down again, select General, then select Connect to Network Folder, the step uses the following settings, change Domain\User to use the domain credentials of a user account that you want to make the connection:

 

Name: Connect to Network Folder

Drive: Z:

Account: Domain\User

 

connect to network.png

 

finally, click on the Add drop down again, select General, then select Run Command Line, the step uses the following settings:

 

Name: Lenovo UEFI Video Fix

Command Line: %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File "Z:\Lenovo UEFI video fix.ps1"

 

as shown below:

 

Powershell step.png

 

Tip: If you don't want to use a connect to network folder step, then you can package the PowerShell script above into it's own package and run the script directly from the package.

 

Apply the settings and you are ready to test the results.

 

 

Step 5. Verify the results

After making the changes above you can now UEFI network boot any of those Lenovo devices and you should see the change kick in once the group runs. To make things easy for you I'm including a video of what that process looks like. To see the video see below.

 

 

Troubleshooting

To troubleshoot this script, check out the logfile generated by the script X:\Windows\Temp\SMSTSLOG\UEFIVideoDriverinWinPE.log. Below is a screenshot of a successful dynamic UEFI video fix.

 

UEFIVideoDriverinWinPE log file.png

 

Summary

Deploying operating systems on UEFI devices using UEFI network boot is even better when using PowerShell and dynamic solutions in System Center 2012 R2 Configuration Manager.

Share this post


Link to post
Share on other sites

Hi Niall,

 

Thanks a lot for all of you great things you put together,

 

I have tried it from a bit different perspective, but have run into an issues with the T450s, it gave me the error code: drvload unable to load 0x80070070, which after a bit of googling has been translated "Not enough space". I have looked into a scratch space, but as far as I remember, no matter what's set on the Boot Image in ConfigMgr it will automatically be set based on the ram you have on the box. Anyway when you dir it, you will see it's 512mb.

 

Have you run into such an issue before? It is a Win10 PE. Using "Intel HD Graphics Driver for Windows 10 (64-bit) - ThinkPad T450, T450s"

 

Thanks a lot

Kacper

Share this post


Link to post
Share on other sites

Hi Niall,

 

I will have to drive the file through the security department, to get it hashed... Could you take a peek look if that's enough.

 

When I run manually the drvload, this is the output

X:\sms\bin\x64>drvload "Xxxxxxxxxxxxxxxxxxxx\ThinkPad T450s\ki111247.inf"
DrvLoad: Unable to load Xxxxxxxxxxxxxxxxxxxx\ThinkPad T450s\ki111247.inf (Error 0x80070070).

Memory:

PS X:\sms\bin\x64> Get-WmiObject -class "Win32_PhysicalMemory" -namespace "root\cimv2" | % {"Capacity: " + ($_.Capacity / 1GB) + " GB"}
Capacity: 4 GB
Capacity: 16 GB

SMSTS:

Executing command line: smsswd.exe /run: %SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File "XXXXXXXXXXXXXLenovo UEFI video fix.ps1"	TSManager	06/06/2016 14:38:26	1360 (0x0550)
[ smsswd.exe ]	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
PackageID = ''	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
BaseVar = '', ContinueOnError=''	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
ProgramName = 'X:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -WindowStyle Hidden -ExecutionPolicy Bypass -File "XXXXXXXXXXXXXXLenovo UEFI video fix.ps1"'	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
SwdAction = '0001'	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
Command line for extension .exe is "%1" %*	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
Set command line: Run command line	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
Working dir 'not set'	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
Executing command line: Run command line	InstallSoftware	06/06/2016 14:38:26	2040 (0x07F8)
InstallSoftware	06/06/2016 14:38:34	2040 (0x07F8)
nhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception.	InstallSoftware	06/06/2016 14:38:34	2040 (0x07F8)
   at System.Threading.ThreadPool.NotifyWorkItemComplete()	InstallSoftware	06/06/2016 14:38:34	2040 (0x07F8)
   at System.Threading.ThreadPoolWorkQueue.Dispatch()	InstallSoftware	06/06/2016 14:38:34	2040 (0x07F8)
InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
    Directory: X:\Windows\Temp\SMSTSLOG	InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
Mode                LastWriteTime         Length Name                       	InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
----                -------------         ------ ----                       	InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
-a----         6/6/2016   2:38 PM              0 UEFIVideoDriverinWinPE.log 	InstallSoftware	06/06/2016 14:38:37	2040 (0x07F8)
Process completed with exit code 3221225501	InstallSoftware	06/06/2016 14:39:11	2040 (0x07F8)
Command line returned 3221225501	InstallSoftware	06/06/2016 14:39:11	2040 (0x07F8)
Process completed with exit code 3221225501	TSManager	06/06/2016 14:39:11	1360 (0x0550)
!--------------------------------------------------------------------------------------------!	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Could not find CCM install folder. Don't use ccmerrors.dll	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Failed to run the action: Lenovo UEFI Video Fix. 
Unknown error (Error: C000001D; Source: Unknown)	TSManager	06/06/2016 14:39:11	1360 (0x0550)
MP server xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Setting authenticator	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Set authenticator in transport	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Sending StatusMessage	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Setting message signatures.	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Setting the authenticator.	TSManager	06/06/2016 14:39:11	1360 (0x0550)
CLibSMSMessageWinHttpTransport::Send: URL: xxxxxxxxxxxxxxxxxxxxxxxxxxx  CCM_POST /ccm_system/request	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Request was successful.	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Set a global environment variable _SMSTSLastActionRetCode=-1073741795	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Set a global environment variable _SMSTSLastActionSucceeded=false	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Clear local default environment	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Let the parent group (EUC - UEFI video driver fix) decides whether to continue execution	TSManager	06/06/2016 14:39:11	1360 (0x0550)
The execution of the group (EUC - UEFI video driver fix) has failed and the execution has been aborted. An action failed.
Operation aborted (Error: 80004004; Source: Windows)	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Could not find CCM install folder. Don't use ccmerrors.dll	TSManager	06/06/2016 14:39:11	1360 (0x0550)
Failed to run the last action: Lenovo UEFI Video Fix. Execution of task sequence failed.
Unknown error (Error: C000001D; Source: Unknown)	TSManager	06/06/2016 14:39:11	1360 (0x0550)

UEFIVideoDriverinWinPE:

DriversPath = XXXX
Lenovo found, continuing...
Detected the following model:  ThinkPad T450s
Drivers should be found at:  XXXX\ThinkPad T450s
checking if the following folder exists: XXXX\ThinkPad T450s
found a folder name XXXX\ThinkPad T450s matching this Lenovo Product !
about to use DrvLoad to inject the following driver XXXX\ThinkPad T450s\ki111247.inf

Share this post


Link to post
Share on other sites

interesting error:

 

DrvLoad: Unable to load Xxxxxxxxxxxxxxxxxxxx\ThinkPad T450s\ki111247.inf (Error 0x80070070).

 

when i see what 0x80070070 means i get this

There is not enough space on the disk.

Source: Windows
-----

so could your boot image be lacking space due to (lack of ram) or is the storage issue on your hard disc.

Share this post


Link to post
Share on other sites

Hi,

 

Yeah I know... there is no problem to load different drivers, which are smaller.

 

Disk space:

 

Directory of C:\

06/07/2016 11:30 AM <DIR> _SMSTaskSequence
0 File(s) 0 bytes
1 Dir(s) 510,844,153,856 bytes free
Directory of X:\
04/26/2016 10:05 AM <DIR> Deploy
06/06/2016 01:51 PM <DIR> Program Files
06/06/2016 01:50 PM <DIR> Program Files (x86)
06/06/2016 01:52 PM <DIR> sms
07/10/2015 12:31 PM <DIR> Users
06/06/2016 01:52 PM <DIR> Windows
0 File(s) 0 bytes
6 Dir(s) 527,466,496 bytes free

 

Memory is 20gb as mentioned earlier.

 

What I have troubleshoot so far, I have tried to hack the WinPE, to change the scratch space to 1024. I could only achieve that with the registry change, not the dism built in command.

For reference, this one is working:

WinPESystemHive\ControlSet001\Services\FBWF
WinPECacheThreshold 0x400

This one is not working:
DISM /image:G:\temp\_1024\bootwim /Set-ScratchSpace:1024

Even the bigger WinPE scratchSpace, will not fit the driver... I'm puzzled now. As a experiment I have tried to copy files over the disk, to check how much I can fit... and it failed. Maybe the hack with extending the ScratchSpace through registry is not really working.

 

I have already check the different drivers for this model, including one directly from Intel, and is also not working.

 

I will try to open a case to lenovo, will update you guys if I find something useful, in worst case scenario the HTA preflight checks for hardware office will have to be resized for lower resolution.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.