# Update OSD Task Sequence

In order to use OneSite as an Alternate Content Provider (ACP) in the WinPE phase of a ConfigMgr task sequence, the task sequence uses a task sequence variable to identify the location of **OneSiteDownloader.exe**. The name of the variable is **SMSTSDownloadProgram**. There are also other Task Sequence variables that can be added to configure settings for OneSite to use, see [Task Sequence Variables](https://docs.adaptiva.com/anywhere/osd-overview/osd-task-sequence-variables).

There are two ways to implement the variable **SMSTSDownloadProgram**:

* a variable within the task sequence itself,
* or as a collection variable against the collection which contains the machines the task sequence will be targeted to.

## Option 1 - Set a Task Sequence Variable

1. Open your OSD task sequence by right-clicking and selecting Edit.
2. In the left-hand navigation, under **Install Operating System**, select **Apply Operating System** task.
3. Click **Add > General > Set Task Sequence Variable** and configure the following values:

   * Name: **Set SMSTSDownloadProgram**
   * Variable: **SMSTSDownloadProgram**
   * Value: **%systemdrive%\OneSite\OneSiteDownloader.exe**

     This is the location of the OneSiteDownloader relative to the root (X:) of your boot image.

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-bc924f071d182b999a1049224467a6aa42e7e62e%2Fset-ts-variable.png?alt=media)

You should also add the **OneSiteServerNameOrIP** variable to ensure that the OneSiteDownloader can communicate with the Adaptiva server to assist for P2P discovery.

1. Click a second **Task Sequence Variable** and configure the following values:

   * Name: **Set OneSiteServerNameOrIP**
   * Variable: **OneSiteServerNameOrIP**
   * Value: The FQDN or IP address of the Adaptiva server.

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-79c912ea619187fbd03e41ad91d42e82adeaeb08%2Fts-server-variable.png?alt=media)

## Option 2 - Set a Collection Variable

1. In the ConfigMgr console, navigate to **Assets and Compliance > Device Collections > Operating System Deployment**.
2. In the details pane, right-click a device collection and click **Properties**.
3. Select the **Collection Variables** tab and add a new variable:

   * Name: **SMSTSDownloadProgram**
   * Value: `%systemdrive%\OneSite\OneSiteDownloader.exe`

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-af69b24f93f696df24d2c32b0771782d3b02b979%2Fimage2.png?alt=media)
4. Add a second variable name **OneSiteServerNameOrIP** to allow the OneSiteDownloader to communicate with the Adaptiva server to assist for P2P discovery.
   * Name: **OneSiteServerNameOrIP**
   * Value: `<Adaptiva Server FQDN>` OR `<Adaptiva Server IP>`

## Modify the OSD Task Sequence

### Copy the OneSiteDownloader to C

The OneSiteDownloader can be used in your task sequences after the WinPE section is completed and the build machine has been booted into Windows. Because the WinPE `X:` drive will no longer be available after booting into Windows, a task sequence step must be included to copy the OneSiteDownloader utility to the local `C:` drive.

1. Open your OSD task sequence by right-clicking and selecting **Edit**.
2. In the left-hand navigation, select **Apply Operating System** task and click **Add > General > Run Command Line**.
3. Configure the Add the **Run Command Line** task with the following values:

   * Name: **Copy OneSiteDownloader to C:**
   * Command line: `xcopy.exe %systemdrive%\OneSite C:\OneSite /y /s /i`

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-7a16282a2aee2f09a9f9d2aea5538929dc2d87b4%2Fts-copy-cmd.png?alt=media)

### Create OneSiteDownloader Firewall Rule

Once in the Windows environment, the Windows firewall may block OneSiteDownloader communication. After the Setup Windows and ConfigMgr task, a *Run Command Line* task should be added to open the Windows Firewall to OneSiteDownloader.

1. In the left-hand navigation, under **Setup Operating System**, select **Setup Windows and Configuration**.
2. Click **Add > General > Run Command Line** and configure the following values:

   * Name: **OneSiteDownloader Firewall Rule**
   * Command line: `netsh advfirewall firewall add rule name=OSD dir=in action=allow program=%systemdrive%\OneSite\OneSiteDownloader.exe enable=yes`

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-95ced5f55a5a6b95ea5204c2426d8badeab9bd53%2Fts-firewall-cmd.png?alt=media)
3. Click the **Options** tab in the tasks sequence step.
4. Click **Continue on error**. In some versions of WinPE this command may not be supported, so enable Continue on error.
5. Since OneSiteDownloader was copied to the `C:` drive, the SMSTSDownloadProgram must be set again to point to the new location.
   * Add the task: **Set Task Sequence Variable**
   * Variable: **SMSTSDownloadProgram**
   * Value: %systemdrive%\OneSite\OneSiteDownloader.exe

![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-262785db5e5062dba83cc0799c92ed02c9e8a9a1%2Fimage11.jpeg?alt=media)

### Install the Adaptiva Client Package

OneSiteDownloader can't be used to download CI based content such as Software Updates or Applications, so before the Install Updates or any Install Application tasks, add an **Install Package** task to install the Adaptiva client.

1. In the left-hand navigation, under **Setup Operating System**, select **Setup Windows and Configuration**.
2. Click **Add > General > Run Command Line** and configure the following values:

   * Name: **Install Adaptiva Client**
   * Package: **Adaptiva Client**
   * Program: **InstallOrUpgrade**

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-f44fb57a07e6f02003921752df930e7a24b6061f%2Fts-client-install.png?alt=media)
3. Click **Add > General > Run PowerShell Script** and configure the following values:

   * Name: **Await Adaptiva Client License**
   * PowerShell script:

     ```powershell
     $timeout = New-TimeSpan -Minutes 15
     $endTime = (Get-Date).Add($timeout)
     $regLicKey = "HKLM:\Software\adaptiva\client" $regLicValue = Get-ItemProperty -path $regLicKey | Select-Object -ExpandProperty 'license.onesite' -ErrorAction Continue
     do {
     Sleep -Seconds 30
     $regLicValue = Get-ItemProperty -path $regLicKey | Select-Object -ExpandProperty 'license.onesite' -ErrorAction Continue
     }
     until ($regLicValue -eq "true" -or ((Get-Date) -gt $endTime))
     ```
   * Time-out (minutes): 15

   This PowerShell script will checkt that the Adaptiva Client has an ID and a license. If 15 minutes pass without a successful check, this task will fail.
4. Close the task sequence.

### Ensure Task Sequence is using the OneSite Boot Image

1. Prior to deploying the task sequence, open the task sequence **Properties**, select the **Advanced** tab, then click the **Browse** button to select the **OneSite Boot image** created in the previous section.

   ![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-3c9d8edcaca388d8cea17ec9a1cff31300cc1106%2Fts-boot-image.png?alt=media)

At this point the Task Sequence is ready to be added to a content push policy. For additional options for OneSiteDownloader and task sequence variables, see [OneSiteDownloader Task Sequence Variables](https://docs.adaptiva.com/anywhere/osd-overview/osd-task-sequence-variables).

## Logging and Exit Codes

Whenever the OneSiteDownloader utility is executed, it creates a log file named **OneSiteDownloader.LOG** in the same folder where it was run. This also includes on the `X:` drive in WinPE.

Whenever the OneSiteDownloader tool is executed, it returns an exit code of `0` in case of success, and a non-zero WIN32 error code in case of failure. The cause of failure for any error may be determined by examining the **OnesiteDownloader.LOG** file and decoding the exit code using the Windows net helpmsg command.

For example, if a code `5` is returned, you can run the following command in a command prompt for more information: `net helpmsg 5`.

![](https://3413670903-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTcngs4tdupbQfdQ7fXLB%2Fuploads%2Fgit-blob-a83fd9e40b02c71fa6f0b0885050cde8a110e34e%2Fcmd-helpmsg.jpeg?alt=media)
