CCMEXEC.COM – System Center blog

CCMEXEC.COM – by Jörgen Nilsson

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.

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:

BiosUefi35

Done!

To implement our solution, you need to download Legacy2Uefi as well as TSEnv2.exe from 1E (http://info.1e.com/website-freetools-1e-tsenv2) 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.
    BiosUefi1
  2. Copy the corresponding version of TSEnv2.exe to the x64 as well as the i386 subfolder.
    BiosUefi2
  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:
    BiosUefi3

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:

BiosUefi33

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

BiosUefi34

The result should look like this:
BiosUefi4

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

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.
BiosUefi6

Make sure to also include “copy.cmd” from Legacy2Uefi.zip.

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”.
BiosUefi7

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).
BiosUefi8

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.

Legacy2Uefi.zip contains a folder with only two files:
BiosUefi9

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:

BiosUefi10

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

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”.
BiosUefi12
BiosUefi13


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.
BiosUefi14

”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”.
BiosUefi15

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).

BiosUefi16

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.
BiosUefi17

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:
    OnedriveSetup1
  • 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.
    OnedriveUpdate5

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
    OnedriveUpdate
  4. Create a Package/program in Configuration Manager
  5. Add it to your Task Sequence
    OnedriveSetup7

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.
OnedriveUpdate6

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 (http://aka.ms/intune)
  2. Log on to the office 365 portal and create a couple of test users (https://portal.office.com/AdminPortal/Home?switchtomoderndefault=true#/users)
    AzureSync1
  3. Log on to the O365 App Registration Tool (https://dev.office.com/app-registration)
    We use the account we created above for the Intune trial.
    AzureSync2
  4. Approve the permissions required for dev.office.com by pressing Accept
    AzureSync3
  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.
    AzureSync5
  6. Copy the Client ID to clipboard and save it in a text file for use with the AzuredirectoryUserSync tool.
    AzureSync6
  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 CCMEXECTP5.onmicrosoft.com -appClientId d089f0bc-123b-4a96-a30f-a3375f3f1ca4 -RedirectURI http://localhost:8000
    You will be prompted to log in.
    AzureSync7
    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.
    AzureSync9
  8. Launch the Configuration Manager console and you will now see the imported users there.
    AzureSync10
  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!
Installapps1

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”

Installapps2

-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.

Installapps3

Installapps4

-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.

Installapps5

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.
    Installapps6
  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”
    Installapps7
  5. Then we add the step to install the applications dynamically.
    Installapps8
  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.

    Installapps9

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.

colleague

I wrote a post on how to add an Internet Explorer shortcut to the Start Menu in Windows 10 which turned out not to be the easiest thing to do. The post can be found here: http://ccmexec.com/2015/09/customizing-the-windows-10-start-menu-and-add-ie-shortcut-during-osd/

When I started to upgrade Windows 10 1507 – 1511 I realized that the “Internet Explorer.lnk” file is actually removed during the upgrade. It is actually removed wherever you put it, Program Files, Windows, Programdata and so on. It is a feature of in-place upgrade that has been around since Windows Vista!. Has it been an issue before? “NO!” but it will be now!

So we need to solve this, when doing modifications to Windows 10 like uninstalling apps and so on we must use a Task Sequence to upgrade from one Windows 10 version to the next otherwise all default apps will be installed and again for instance. So what we do is simply a step that copies the IE icon back after the upgrade is complete and the icon has been removed. The IE Shortcut must be there when the user logs on otherwise it will be removed from the start menu.

In our Windows 10 to Windows 10 upgrade Task Sequence it would look like this.

CopyIEicon1

What I did was add a PowerShell script to the package I used for the Start Menu customization that copies the IE icon as well as imports the start menu layout in the first place.
Basically it is the same script but I don’t import the default start menu, I only copy the IE icon back to the location is was before the Windows 10 1507 – Windows 10 1511 Upgrade. So a very simple solution!

The script only does the copying of the IE shortcut so it is very simple.

Copy-Item -Path $PSScriptRoot'\StartMenufiles\internet explorer.lnk' -Destination $env:SystemDrive'\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories'

Copy-Item -Path $PSScriptRoot'\StartMenufiles\internet explorer.lnk' -Destination $env:SystemDrive'\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories'

That way we still have the Internet Explorer shortcut on the end users Start Menu after the upgrade.

CopyIEicon2
I will cover this and much more on mine and Ronni Pedersen’s session at the Midwest Management Summit (MMS) in just  a couple of weeks! http://mmsmoa.com/ Hope to see you all there!

In Windows 10 by default a reminder is displayed to the end-user in the Notification area if there are three apps or more that launch automatically when you login. At least I think this is very annoying and it causes end-users to call the servicedesk and ask how they can disable the applications to improve performance. This is not a wanted scenario!

DisableApps_1

This notification is triggered by a Schedule Task called “StartupAppTask” that resides under Microsoft, Windows and Application Experience in the Task Scheduler. So to stop it we simply disable that Task and then the reminders go away! :D

DisableApps_2How do we do this during OSD you might ask?

Well we run a simple Powershell script when we are on the full Operating System in the Task Sequence like the example below shows, then the task is disabled and never run at all for the end-users.

Powershell command:

powershell.exe -NoProfile -ExecutionPolicy ByPass -Command "&{ Disable-ScheduledTask -TaskName '\Microsoft\Windows\Application Experience\StartupAppTask'}"

DisableApps_3

You can disable this task in many ways, I prefer to do it this way then I know that it is always disabled.

I hope this is useful to more than me!

I get a lot of questions if there are any difference in functionality in Intune Standalone and in Hybrid with Configuration Manager. There are a lot of differences, in this post I will show how to setup the Apple Volume Purchase Program(VPP) integration in Configuration Manager 1602 with Intune and cover the differences in functionality between Intune Standalone and Configuration Manager/Intune Hybrid.

The Apple Volume Purchase Program comes in two different version one for Business and one for Education. Both programs work in the same way making it possible to volume purchase applications and deploy them with a MDM solution of your choice. When you sign up you download your Apple VPP token that is then imported into the MDM solution that you want to use. This token is valid for one year. More information can be found here: http://www.apple.com/business/vpp/

There are some things to keep in when it comes to the Apple VPP Program in Configuration Manager, for more information see the following link where these limitations are taken from. https://msdn.microsoft.com/en-us/library/mt627954.aspx

  • Only one VPP account and token is supported
  • Only the Apple Volume Purchase Program for Business is supported.
  • Once you associate an Apple VPP account to Intune, you cannot subsequently associate a different account. For this reason, it’s very important that more than one person has the details of the account you use.
  • If you have previously used a VPP token with a different MDM product in your existing Apple VPP account, you must generate a new one to use with Configuration Manager.
  • Each token is valid for one year.
  • By default, Configuration Manager syncs with the Apple VPP service twice a day to ensure that your licenses are synchronized with Configuration Manager.
  • Only changes to your licenses are synchronized. However, once every 7 days, a full synchronization will be performed.
  • When you click Sync to perform a manual sync, this will always perform a full synchronization.
  • If you need to recover, or restore you Configuration Manager database, we recommend that you perform a manual sync afterwards to ensure that your synchronized license data is up to date.
  • While you can deploy iOS volume-purchased apps to user or device collections, VPP apps you deploy to a device without a user (for instance, a device you enrolled without user affinity using the Device Enrollment Program (DEP) or Apple Configurator) will not be installed.

The differences between Intune Standalone and Intune/ConfigMgr Hybrid are actually bigger than you think. The table below illustrates the different deployment types and targets and if it works in Standalone/Hybrid.

Deployment Type

Intune/ConfigMgr Hybrid

Intune Standalone

User Required

X

X

User Available

X

Device Required

X

Device Available

So how do we configure Apple VPP in Configuration Manager? To start with you need the following:

  • Apple VPP Token that is to be used.
  • An account that is Global Administrator in your Intune Subscription used for Configuration Manager.

In the Configuration Manager Admin Console the Apple VPP Program is configured in under Software Library as shown below.

VPP2

We select to add “Create Apple Volume Purchase Program Token” which actually doesn’t create a token for you, you must have your token available.

VPP3_1

VPP4

In the next dialog you must log on to Intune with an account with Global Administrator permissions. Note that if you log on with an account without the required permissions the wizard will fail with a cryptic error message so make sure you have the correct permissions for your account.

VPP5

Then the token is uploaded.

VPP6

When the token is uploaded a Synchronization is started, the full synchronization downloads the information about which apps you have bought with your Apple VPP account and the license information for them how many you bought and how many are in use. After that Configuration Manager will synchronize twice a day to ensure that the license information is updated and it does a full synchronization once a week.

VPP7

Under the licensed apps we now have our applications and all information about them available in the console.

VPP8

We can now deploy the iOS application that we downloaded the information for through the Apple VPP program.

VPP9

We select the “App Package for iOS from App Store” option and then Browse.

VPP10

In the next dialog we now have two tabs, one for the App Store and one for Apple Volume Purchase Program and under the “Apple Volume Purchase Program” we can now choose the apps that are bought through the Apple VPP program and deploy them.

VPP11

We can then import the application based on the information from the Apple VPP Program.

VPP12

VPP13

Now we have an application with a link to the application in the Apple VPP Business Store which we can deploy as normal in Configuration Manager. We can deploy it both to Users and to Devices and that is the big difference between Intune Standalone and Intune/Configuration Manager in Hybrid as I mentioned above. When we deploy it to devices the device must have a user affinity which means that it doesn’t work for iOS devices enrolled via DEP without user affinity.

In Intune standalone we can only deploy Apple VPP apps to Users and only as required as shown here as well.

VPP9_2

We select the user group, only user groups are shown.

VPP9_I

And then we select deployment action and only Required Install is allowed.

VPP9_3

Support for Apple VPP program in Intune has been one of the most frequent feature requests for Intune and it is great that it is available!
It is also cool that Hybrid actually delivers!! Hybrid Rules!

  • Currently, each organization can have only one VPP account and token.

  • Only the Apple Volume Purchase Program for Business is supported.

  • Once you associate an Apple VPP account to Intune, you cannot subsequently associate a different account. For this reason, it’s very important that more than one person has the details of the account you use.

  • If you have previously used a VPP token with a different MDM product in your existing Apple VPP account, you must generate a new one to use with Configuration Manager.

  • Each token is valid for one year.

  • By default, Configuration Manager syncs with the Apple VPP service twice a day to ensure that your licenses are synchronized with Configuration Manager.

    Only changes to your licenses are synchronized. However, once every 7 days, a full synchronization will be performed.

    When you click Sync to perform a manual sync, this will always perform a full synchronization.

  • If you need to recover, or restore you Configuration Manager database, we recommend that you perform a manual sync afterwards to ensure that your synchronized license data is up to date.

  • While you can deploy iOS volume-purchased apps to user or device collections, VPP apps you deploy to a device without a user (for instance, a device you enrolled without user affinity using the Device Enrollment Program (DEP) or Apple Configurator) will not be installed.

In Configuration Manager CB 1511 the Windows 10 Servicing feature was introduced which gives us a great view of the Windows 10 versions used in our environment and a tool to schedule the updates of Windows 10 versions.

Windows10Servicing0

What is happeing when we create Service Plans is basically an ADR which deploys the Windows Upgrade packages according to the Service Plan. In 1511 there was an issue that all Windows 10 versions where downloaded when the ADR ran, there are some workarounds like blocking the non wanted versions of Windows 10 using the WSUS Console. This is now fixed in 1602, there is a new option to filter out which versions of Windows 10 we want to deploy.

The new step in 1602 is Upgrades it didn’t exist in 1511. In my case i select “Swedish” and “Enterprise,” using the “,” to filter out the Enterprise N version which I don’t want to download or deploy.

Windows10Servicing2

The preview feature is great! using it we can make sure only the Windows 10 versions we want to deploy will be downloaded and used.
Windows10Servicing3If you haven’t tried the new Windows 10 servicing feature before it is time to start now.
The new update model of Configuration Manager is great, fixing issues and adding feature faster than ever before!!