Introduction
Recently I put together an MECM task sequence to install Windows 11 Enterprise. The task sequence would run through and complete all the steps successfully. After completion the "Let's connect you to a network" window would appear. The engineer then had to click on "I don't have internet access" and then on "Continue with a Limited setup" in that order, to arrive at the sign in page. Yes this is only two mouse clicks but I did want to bypass this in an automated way and arrive at the sign in page without this manual input.
The Fix - Part 1
The key to bypassing this "Let's Connect you to a network" screen was to kill the oobenetworkconnectionflow.exe process using the taskkill.exe tool. If run from a command prompt, the line would be as follows:
taskkill /F /IM oobenetworkconnectionflow.exe
The Problem
Initially I thought that creating a task sequence step to run this command at the end of the Task Sequence would do the trick, however it did not. This is because the Network Connect page only appeared after the task sequence completed.
My next idea was to run the command as a value for the SMSTSPostAction task sequence variable. This variable allows you to specify a command to run after the task sequence completes, but before exiting the task sequence - which sounds a bit contradictory. This approach did not work either - probably because the Network Connect page had not started at the point in time at which the SMSTSPostAction command executed.
The Fix - Part 2
The taskkill command had to be run at a time that I was sure the oobenetworkconnnection.exe
process was actuated - that is, at a time in which the Let's connect to a network was really displaying on the screen. This occurred 30-60 seconds after the completion of the task sequence. Thus I created a PowerShell script that would create a task schedular job to run two minutes after the time the script was run. The script would be run as the last step in the build task sequence.
This is the PowerShell script:
$execdate=(get-date).addminutes(2)
$exectime=($execdate).timeofday
$hour=[string]$exectime.hours
$minute=[string]$exectime.minutes
$time=$hour+":"+$minute
$sta=new-scheduledtaskaction -execute "taskkill" -argument "/F /IM oobenetworkconnectionflow.exe"
$stt=new-scheduledtasktrigger -once -at $time
register-scheduledtask CancelNetworkFlow -action $sta -trigger $stt -runlevel highest -user "NT AUTHORITY\SYSTEM"
I saved this script as stopncf.ps1
The MECM Package
There are many different ways to run a PowerShell script in MECM - I got this one working by using the good old fashion legacy package. I then plugged this as a last step in the OSD Windows 11 task sequence as an Install Package step. The package contained a Program Command Line consisting of the following:
powershell.exe -executionpolicy unrestricted -file stopncf.ps1
The package content consisted of the above PowerShell script called stopncf.ps1.
I have included below the various screenshots of the package settings, in the case that you would like to follow a similar solution. The package name is StopNWC.
The Task Sequence Step
As already mentioned this package was added as the last step of the Window 11 OSD task sequence.
And here are the details of the sequence step.
This issue is normally seen during the task sequence installation itself - but as can be seen it may occur after the task sequence completes. We can use the solution presented here to remove this unwanted screen, using the task schedular service and a little bit of PowerShell. For those who like to have the entire process automated, I hope you have benefited from this little blog.
No comments:
Post a Comment