CCMEXEC.COM – System Center blog

CCMEXEC.COM – by Jörgen Nilsson

I have written posts both about how to uninstall builtin apps in Windows 10 using Powershell and how to block them with Applocker before so this is just a note that you will need to use Applocker once more.
Now that Windows 10 1607 is here we have a new app called “Connect” which we cannot uninstall much like the Contact Support app.


The connect app turns your PC into a Miracast Receiver , which can be useful but not really in an enterprise.

If we try to uninstall it, we get the following message, that it is part of the Operating System and cannot be removed.

Remove Connect

We can block it using Group Policy as I have described before with the Contact Support app and Microsoft Feedback app.

If you are doing that already we only need to edit the Group Policy and add the following app as well. In the Group Policy add a new Package app rule for the Connect app

So we end up with the following rules together with the Contact Support app and Feedback app as I have in my Group Policy since Windows 10 1507 and 1511.

When deploying Windows 10 1607 the anniversary update for the first time I realized I need to be able to filter applications and also Task Sequence steps based on builds in the future. Why? Well I am lazy so I just copied my existing Windows 10 deployment Task Sequence and it failed when deploying applications as it included both the App-v client and the UE-V Client installations and those are now builtin Windows 10 and the installation will fail.

So here are two ways of creating a Global Condition that can be used as requirements for the different deployment types in the application model.

Global Condition using Buildnumber as a variable

This will give us the possibility to enter different Buildnumbers in the Deployment Type Requirements as shown below. So we can type 14393, 10586 or whatever we need it to evaluate on the clients for the deployment type to install.


Global4To create it do the following:

1.In the Configuration Manager Console we select Create Global Condition under Software Library/Application Management/Global Conditions

2. We use the values below


3. Done!

Global Condition using a specific Buildnumber

We can also create a Global Condition for a specific build number, so that we don’t have to type the build number in the deployment type Requirement like shown below when selecting it, we use the “Existential” option instead of string.


This is created in the following way:

1.In the Configuration Manager Console we select Create Global Condition under Software Library/Application Management/Global Conditions

2. The only difference is that now we enter the WQL Where query as well as shown below.


3. Done!

When we deploy the UE-V application to a Windows 10 1607 machine we get the following in the deployment status to verify that it works.
Global Condition

I hope it is useful!

Windows defender has become even better in the Windows 10 1607 release which is great! But it has also added a first-run dialog for each user that launches the Windows Defender UI.
Defender 1607

This is kind of annoying as it doesn’t check i the settings are already configured and a normal user doesn’t have permissions to turn it on as it requires local admin permissions. So after a little Regshot usage, the registry value that is set after you press close is the following: HKCU\Software\Microsoft\Windows Defender\UIFirstRun with a value of 0.
Defender1So by using a script or a Group policy preference as shown below we can disable that end-user dialog. I haven’t found it in the group policy settings for Windows 10 1607 which I think it actually should have been. Enterprises will want to turn this of. Defender2I hope that can be useful!

I just had to write this post as one of my User-voice items for Configuration Manager and favorite new feature is included in this release, the Company Logo is now displayed in end-user dialogs and Software Center.

What is new in Configuration Manager 1607 Technical Preview, you can read the full list here: but basically it is four things:

  • Customizable branding for end-user dialogs, this is so great! we get the same Company logo displayed in for instance restart dialogs as in Software center, defined in the Intune Subscriptions as we have done for mobile devices before.16073
    Configured under Intune Subscription, Company Logo 16074
  • Manage duplicate hardware identifiers, Makes it possible to add Mac or SMBIOS number under Hierarchy settings to exclude them from PXE Boot and Client Registration. It sure beats the hacks we had to do before!! Awesome! I really would still like a switch to ignore MAC address totally but this is really good!
  • Microsoft Operations Management Suite (OMS) connector, Syncs data to OMS, I haven’t had the time to test it out yet.
  • Windows 10 Edition Upgrade, makes it possible yo upgrade Windows 10 from Pro to Enterprise without media! Great!
    UPDATE: The client setting below is not the place where we configure it.

    Update: the client setting screen shown below doesn’t seem to do anything, it should be the already existing dialog that is under Compliance Settings and Windows 10 Edition Upgrade that should be used. However it is not working for me, troubleshooting it now, will update the post again.
    I will continue my testing of Configuration Manager 1607 all night, let’s see if there are more new features!

This solution has been created and tested by a colleague of mine Johan Schrewelius, he has done most of the work so I cannot give him enough credit for this. We have been using it for a while now and it works great, it is 100% unsupported ;-) as we change values on a read-only variables in the TS.

If you are using Configuration Manager 1610 or later there is now a supported built-in way to do this.

1         Background

The release of Windows 10 in combination with steadily increasing security demands means an operating system upgrade, or fresh install, today also includes security measures that not long ago where sort of luxury or only experimental.

Two major such are UEFI and Secureboot; a significant challenge as not even Configuration Manager 1602 supports a seamless transformation from Legacy Bios to UEFI.

This post describes our method of achieving the desired; one (1) Task Sequence that starts in Legacy mode and results in an UEFI configured computer with Secureboot enabled. A script and files for configuring HP computers have been included as example. No PXE boot is required as we boot from the local disk when we reboot. This is a short flow of what happens:

1. Configure Bios to UEFI and Secureboot using the tool for the vendor/model

2.Then we partition the local disk to GPT and format it

3.Copy an exported Boot image from a package to the local disk

4.Change the value for a read-only variable _SMSTSServiceStart using the 1E tool

5.Restart the computer and boot to the local installed Operating System

6.Change the second read-only variable _SMSTSBootUEFI to true and then the TS and all builtin steps for formatting will see that it is a machine running UEFI.

In the Task Sequence it looks like this:



To implement our solution, you need to download Legacy2Uefi as well as TSEnv2.exe from 1E ( 1E has been generous enough to share this powerful tool with us, and we cannot thank them enough.

2         Obstacles

There are two major obstacles that prevents us from achieving our goal using a standard TS.

Firstly, we will not be able to apply a boot-image nor an operating system to a GPT disk on what is detected as a MBR System.

Secondly, if we (which we nevertheless will do later) apply bootable media to disk by running a script we will not be able to restart the computer in a controlled fashion as built-in controls (smsboot.exe) will prevent this based on inconsistencies in TS configuration, i.e.  the TS-variable “_SMSTSServiceStartType” not being set to auto, which is required to allow rebooting to an installed operating system. Unfortunately, this variable is read-only and we cannot modify it using supported means. But what if we use unsupported means……

3         Read-only TS-variables < TSEnv2.exe

It is usually not recommended to use unsupported means; this however could be the time when circumstances call for it? TSEnv2.exe is able to modify read-only TS-variables and since that is what stands between us and a successful Legacy to UEFI transformation, that’s exactly what we are going to do.

TSEnv2.exe comes in both 32- and 64-bit versions, it is also depending on native Configuration Manager libraries, at least tscore.dll. This makes it reasonable to include it in our boot images using OSDInjection.

4         OSDInjection

To include TSEnv2.exe in already existing, as well as in new, boot images do the following on the primary site server or CAS that “owns” the images. And yes you can use the MDT feature as well to include the files when you create a new MDT Boot Image instead.

  1. Localize your ..\OSD\bin directory.
  2. Copy the corresponding version of TSEnv2.exe to the x64 as well as the i386 subfolder.
  3. Once the files have been copied we need to tell ConfigMgr to actually include them the next time an image is created or updated. This is done by editing “osdinjection.xml” which is found in ..\bin\x64:

Remark – there’s only one osdinjection.xml, not one per architecture.

Remember to Backup osdinjection.xml before editing.

osdinjection.xml holds the “recipe” for boot images and needs to be supplemented with information about the new files.

Open osdinjection.xml in notepad or similar.

As we know there’s already a native file with similar name (tsenv.exe) we will search for that and copy the section, thus avoiding misspelling.

First hit when searching should give you this:


Copy (duplicate) the section and replace the file name:


The result should look like this:

Repeat for x64 (second hit when searching for tsenv.exe):

Save and close osdinjection.xml. Next time a boot image is updated on distribution points TSEnv2.exe will be included.

5         Bootable media Package

As stated earlier we will apply bootable media to disk by script, therefor we will need to create a package containing the necessary files. Use the same procedure as when creating bootable media for use on a USB boot stick, then mount the iso-file and copy the entire content to a new folder on your package share.

Remark – you cannot reuse an old iso; it has to be “fresh” with TSEnv2.exe included.

Make sure to also include “copy.cmd” from

Create a package in ConfigMgr from the folder, do not create any program.

6         Task Sequence

At this point boot images should be updated and include TSEnv2.exe. We should also have a new package including the small copy.cmd command file. The rest of the work is done in the TS-editor, let’s start….

6.1       Create a new group

Create a new group, call it “Transform to UEFI”.

In our case we have a few extra conditions but as a minimum you should check that the machine isn’t already configured for UEFI (_SMSTSBootUEFI equals False).

The steps within in the group will be explained over the next couple of pages.

6.2       TS Steps

6.2.1      UEFI Config

This step will have to be adapted to local circumstances. It’s simply an example that shows how to reconfigure a HP Laptop to UEFI mode. contains a folder with only two files:

ConfigUEFI.ps1 is designed to utilize HP’s Bios Configuration utility, which is not included. You also need to create your BIOS password file with the HP tool.

uefi.txt contains a minimum of settings to configure UEFI with SecureBoot.

To make this fully operational more files are needed, these files must be added locally. If you’re an administrator with experience in HP computer this is hopefully enough information to get it working, this is a picture of a functional set of files:


As we prefer keeping bios config files on a network share the step looks like this at most of our customers:

Command: powershell.exe -NoProfile -ExecutionPolicy ByPass -File “%BiosShare%\%Model%\BCU\ConfigUEFI.ps1″

If your running Dell, Lenovo or any other brand – modify as needed. If you don’t have Powershell included in your boot images the script is useless and has to be replaced.

6.2.2      Partition Disk 0 – UEFI Simple

Use a standard “Format and Partition Disk” step to create a GPT disk with a minimal UEFI-compatible partition. The automatically assigned drive letter will be stored in “OSDisk”.

6.2.3      Copy Boot Media to Disk

This is a straight forward “Run Command Line” step that uses the media package and “copy.cmd” to copy the media (iso) content onto the new partition.

”OSDisk” contains the drive letter and tells copy.cmd where to put the content.

Command: copy.cmd %OSDisk%

6.2.4      SET _SMSTSServiceStartType=auto

Another “Run Command Line” step; that invokes TSEnv2.exe and sets ”_SMSTSServiceStartType” to ”auto”.

Command: TSEnv2.exe set _SMSTSServiceStartType=auto

6.2.5      Restart Computer

Next we restart the computer using a standard “Restart Computer” step. Because of the previous modification of the read-only TS-variable we will now be allowed to reboot to the currently installed default operating system, e.g. our media (iso).


6.2.6      SET _SMSTSBootUEFI=true

Finally, we need to modify a second read-only TS-variable. When the TS started the computer was running “Legacy BIOS” and “_SMSTSBootUEFI” was set to “false”.

We need to correct that, as we are now running in UEFI mode.

Command: TSEnv2.exe set _SMSTSBootUEFI=true

7         Done

The rest of the Task Sequence will after the reboot execute as UEFI, no PXE boot needed totally unattended, except for Lenovo Thinkcentre machines but that is a different topic.

When deploying Windows 10 1511 the builtin Onedrive client is now “old” and then it doesn’t support the same group policies as the new Onedrive Next Gen client does. Before we start some background information on the Onedrive client in Windows 10 1511.

  • The onedrive client is installed in this location in the users profile at first logon “C:\Users\%Username%\AppData\Local\Microsoft\OneDrive\Versionnumber”
  • It is installed from “C:\Windows\Syswow64\onedrivesetup.exe”OnedriveUpdate1
  • The command that is run is when the user first logs in is placed in the runonce registry key in the default user hive:
  • When a user first logs on to Windows 10 the Onedrive client is installed in the user profile and then it starts by updating itself to the latest version automatically.

However when a user is fast he/she can start the Onedrive client before the policies are applied that is why I started updating the Onedrivesetup.exe file during OS deployment then I know it is the latest version and it uses the “new” group policies and it is a bit faster for the end user as well.

It is really simple just replace the OnedriveSetup.exe file during OS deployment.

  1. Download the latest version of the Onedrive client
  2. Create a folder in your packagesource folder and place the Onedrivesetup.exe file in that folder.
  3. Create a simple .cmd file in the same folder with the below content will do the trick.
    %SYSTEMROOT%\system32\takeown /f %SYSTEMROOT%\SysWOW64\OneDriveSetup.exe >> %SYSTEMROOT%\logs\Onedrive.log
    %SYSTEMROOT%\system32\icacls %SYSTEMROOT%\SysWOW64\OneDriveSetup.exe /Grant System:(F) >> %SYSTEMROOT%\logs\Onedrive.log
    Copy %~dp0onedrivesetup.exe %SYSTEMROOT%\SysWOW64\OneDriveSetup.exe >> %SYSTEMROOT%\logs\Onedrive.log /Y
  4. Create a Package/program in Configuration Manager
  5. Add it to your Task Sequence

After deployment the Onedrive client will never popup at first logon with the message  that “An Update is being installed” and it will honor the “new” Group Policy settings as well. If they are configured correctly the user will be prompted to logon instead as shown below, and if you disabled “Personal” Onedrive it will not be permitted to use either.

Back in November at the MVP Summit we all where part of a Hackathon where all MVP’s submitted ideas for new features in Configuration Manager. Myself, Kim Oppalfens and Kaido Järvemets where part of a hackathon project that was either mine or Kim’s idea to start with, that can make it easier to do a proof of concept with mobile device management with Intune in Hybrid setup with Configuration Manager. To be able to use Intune in Hybrid with Configuration Manager the users that are allowed to enroll devices must be present in Configuration Manager and match the users in Azure AD which is why it normally requires AzureAD synchronization with AADConnect and matching UPN’s to be in-place before you can use it. To set that up to do a Proof-of-concept for instance can be a huge effort.

It also makes it really simple to setup Intune in a test environment with Technical preview of Configuration Manager. The result of that Hackathon project are now available in Configuration Manager technical preview 1604 and forward in the form of AzuredirectoryUserSync.exe which is located in the Configuration Manager install directory under Tools.

How do AzuredirectoryUserSync work then? It uses the Microsoft Graph API to read the user information from AzureAD and writes them to the Configuration Manager database so we can enroll devices in Intune/Configuration Manager to do a Proof of Concept or setup a test environment with technical preview of Configuration Manager without having to setup AADConnect and handle UPN challenges for instance. It takes 10 Minutes to setup an Intune subscription in Configuration Manager and import the users so you can start enrolling devices.

This is Great stuff!

So how do we do set it up then. To start with we need a Configuration Manager 1604 environment or later and an Intune trial.

  1. Create an Intune trial (
  2. Log on to the office 365 portal and create a couple of test users (
  3. Log on to the O365 App Registration Tool (
    We use the account we created above for the Intune trial.
  4. Approve the permissions required for by pressing Accept
  5. Create an application with the following settings and permissions, this will grant the AzuredirectoryUserSync application permissions to read the user information from AzureAD. Select register App when done.
    Note that it must be exactly the settings displayed below.
  6. Copy the Client ID to clipboard and save it in a text file for use with the AzuredirectoryUserSync tool.
  7. On your Configuration Manager server open an elevated command prompt and run the following command. (Make sure that IE enhanced Security Configuration is not enabled, otherwise it will fail)
    AzureDirectoryUserSync.exe  -Tenant <tenant> -appClientId <appid> -redirecturi http://localhost:8000
    In my example that will be the following:
    AzureDirectoryUserSync.exe -Tenant -appClientId d089f0bc-123b-4a96-a30f-a3375f3f1ca4 -RedirectURI http://localhost:8000
    You will be prompted to log in.
    And to accept the permissions needed for the SCCM AAD Sync application.
    AzureSync8 When the command finishes it looks like this with the numbers of users created in the last line.
  8. Launch the Configuration Manager console and you will now see the imported users there.
  9. We can now configure our Intune Subscription as we normally do and use these users to enroll devices.

This is really cool stuff and makes it so easy to do a Proof of Concept setup of Intune in Hybrid and to use the Technical Preview of Configuration Manager as well!

Note that the tool is in the technical preview which means it can change before release.

As shown and promised at MMS 2016 in Minnesota, probably the best tech event I ever attended by the way!!, I talked about and showed how I have installed applications dynamically using Configuration Manager for the last 4 years during my session with Kent Agerlund and Ryan Ephgrave. I love to keep it simple.

Update: The script is now updated so it supports nested groups and use _SMSTSMachineName as computername. Thanks to Daniel Marklund for great additions!

By reading the application name from the AD group description field instead of from a Collection in Configuration Manager we don’t need access to the Site Server during OSD, the local domain controller will be used. We can also pre-stage computers in AD without having a MAC address yet just by creating the computer in AD and the add it to the groups, the Unknown computer support can be used to deploy the machine for instance, you select the correct name and the applications are installed..

Here is how it works.

- I Use a naming convention for my AD groups which are used in Configuration Manager Collection queries to install applications for example a prefix of “App-“ or “A.” with a suffix for Install groups for instance “.i” something like this “A.7Zip.920.i”


-I put the exact name of the application in Configuration Manager in the Description field of the AD Group. If I don’t want to install the application during OSD simply remove the description.



-In the Task Sequence I run a script that reads the description field from all the groups that starts with my prefix and adds them to the COALESCEDAPPS variable so that they are installed automatically during OS deployment using the built-in step in Configuration Manager.


Then the applications will be installed dynamically

To implement it do the following.

  1. Download the script and add it to a Package in Configuration Manager here: Download
  2. Edit the two variables so it matches your naming convention for your AD groups.
  3. Add the Application name to the AD groups description field in AD as shown above
  4. Add one step in the task sequence that runs the Powershell script, it must be run in the full Operating System after the “Setup Windows and Configuration Manager”
  5. Then we add the step to install the applications dynamically.
  6. On the Options tab for the Install Applications step add the following condition to prevent the task sequence from failing if you don’t have any applications to install.


Then you are all set!

Thanks to my awesome colleague Johan Schrewelius, this script was actually a vbscript when the conference started! Johan rewrote it when I was presenting.