モバイル端末管理 (MDM) を使用したコーディング・エージェントの展開
ベータ版
この機能はベータ版です。使用するには、ワークスペース管理者が [プレビュー] ページから Unity Gateway マネージド構成 を有効にする必要があります。Databricksのプレビューを管理を参照してください。
モバイルデバイス管理(MDM)とUnity Gateway CLIを使用して、Claude CodeとCodexの設定を配布します。ワークスペースでコーディングエージェントの構成を公開し、MDMソフトウェアを使用して各管理対象デバイスをプロビジョニングします。開発者は、エージェントを使用する際に各自のDatabricksアカウントでサインインします。
このガイドには、macOS版Jamf ProとWindows版Microsoft Intuneのプロビジョニング手順が含まれています。Linuxでは、デバイス管理ツールで同じug configure --globalワークフローを使用します。
MDMソフトウェアは、各デバイスで管理者権限を使用してプロビジョニングスクリプトを実行します。スクリプトは、ug、Databricks CLI、およびコーディングエージェントを共有の場所にインストールします。続いてug configure --globalをランし、エージェントのマシン全体の設定を構成します。macOSとLinuxでは、このランにより、公開済みのワークスペース構成からネイティブの管理対象ファイルが再構築されます。Windowsでは、ゲートウェイ構成をClaude CodeとCodexの管理対象ファイルにMergeし、アプリがインストールされている場合はClaude desktopもプロビジョニングします。開発者は管理者権限なしでエージェントを起動します。
このガイドで説明するagent_native_configファイルの再構築と--from-fileのプレビューは、macOSとLinuxに適用されます。Windowsでは、--globalが%ProgramFiles%\ClaudeCode\managed-settings.jsonと%ProgramData%\OpenAI\Codex\requirements.tomlを更新します。Codexには、Windows上でマシン全体に適用されるconfig.tomlレイヤーはありません。
MDMプロビジョニングでは、GitHub Copilot CLIやVisual Studio CodeのGitHub Copilotは構成されません。開発者はug configure --agents copilotを使用してGitHub Copilotを自分でセットアップします。
マシン全体でのランでも、ユーザーごとのMCP接続やスキルには影響しません。各開発者は、ug configureをランするか、ugを通じてエージェントを起動し、それらのリソースを同期します。
MDM でロールアウト
コーディングエージェントを設定する
チームが使用するエージェントを有効にして、ワークスペースで構成を公開します。コーディングエージェントの設定を参照してください。
各有効エージェントには、次のステップのService Principalが使用できるモデルが設定に最低でも1つ必要です。たとえば、Claude CodeにはClaudeモデルが必要です。ug configure --global は、モデルがないエージェントをスキップします。
マネージドエージェントの設定と要件を指定するには、各エージェントのconfigにagent_native_configを追加します。詳しくは、エージェントネイティブのマネージド構成を参照してください。
公開前にcoding-agent-config.jsonとして保存された構成をプレビューするには、次をランします:
ug configure --global --dry-run \
--workspace https://<workspace-hostname> \
--from-file coding-agent-config.json
プレビューには、ugが作成、置換、または削除するファイルとその内容、およびugがそれらのキーを制御しているためにスキップする設定が表示されます。ファイルは書き込みません。
デプロイ予定のものと同じugバージョンおよびオペレーティングシステムでプレビューをランしてください。構成を公開する前に、生成されたファイルを確認してください。
プロビジョニングService Principalを作成する
MDM ポリシーは、ラン中に公開済み構成を読み取るためにのみ Service Principal を使用します。開発者は自分自身として認証を行います。このスクリプトは、Service Principalの資格情報を一時的に使用するため、 ug はワークスペースに接続してコーディングエージェントの構成をdownloadできます。
-
Service Principalを追加します(例:
ug-mdm-provisioning)ワークスペースに。 -
Workspace access (ワークスペースアクセス)の資格のみを有効のままにします。Service Principalには他の資格は必要ありません。エンタイトルメントの管理を参照してください。
-
必要な Unity Catalog 権限を含め、公開された構成内のモデル、MCP サーバー、およびスキルへのアクセス権をService Principalに付与します。モデル、MCP サーバー、スキルへのアクセスの付与を参照してください。
-
Service Principalの シークレット tabで、 シークレットの生成 をクリックします。ローテーションポリシーに適合する有効期間を選択します。 スコープ で、 その他のAPIs をクリックし、
ai-gatewayとunity-catalogスコープを追加して、それぞれを 読み取り に設定します。ステップ1: OAuthシークレットを作成するを参照してください。
-
クライアントIDとシークレットをコピーします。ダイアログを閉じると、シークレットを再度表示することはできません。
MDMソフトウェアでのデプロイ
Install ug in a shared location that developers on the device can read and run, outside root's or SYSTEM's private profile. ug configure --global refuses an installation in a user's home directory. The machine-wide agent settings run ug from the shared installation to authenticate each developer.
Install Codex in a version that meets the Codex version requirement.
- Jamf Pro (macOS)
- Microsoft Intune (Windows)
これらのステップにより、Jamf Proを使用してClaude CodeおよびCodexをmacOSデバイスにデプロイします。各デバイスには以下が必要です:
- ワークスペース URL、PyPI (
pypi.orgおよびfiles.pythonhosted.org)、GitHub (github.comおよびraw.githubusercontent.com)、astral.sh、nodejs.org、およびregistry.npmjs.orgへのネットワークアクセス。 - Xcode 用コマンドラインツール、または
softwareupdateを使用してスクリプトをインストールするためのアクセス許可。ugは GitHub からインストールされますが、これにはgitが必要です。
スクリプトを追加する
-
Jamf Proで、 設定 > コンピュータ管理 > スクリプト > 新規 に移動し、スクリプトに「
Unity Gateway provision」という名前を付けます。![[全般]tabのJamf Pro新規スクリプトページ(表示名:Unity Gatewayプロビジョニング)](/gcp/ja/assets/images/coding-agent-rollout-jamf-new-script-1f06d04f3cb11afb1e7bdfbc722d432c.png)
-
[スクリプト] tabに、以下のスクリプトを貼り付けます。
プロビジョニングスクリプトの表示
#!/bin/bash
#
# macOS MDM provisioning script, written for Jamf Pro policies: install
# ug, the Databricks CLI, Claude Code and Codex machine-wide and run
# `ug configure --global` as root, which builds machine-wide settings
# from the published agent configuration. It also adds aliases to
# /etc/zshrc and /etc/bashrc, so users launch with `claude` or `codex`
# in a new terminal, with no sudo.
#
# Jamf parameters ($1-$3 are reserved by Jamf):
# $4 Databricks workspace URL, starting with https://
# $5 Service principal OAuth client id
# $6 Service principal OAuth client secret
#
# The token is used for this run only; developers sign in with their own
# OAuth. Needs access to PyPI, GitHub, astral.sh, nodejs.org and npmjs.org.
set -euo pipefail
umask 022
export HOME=/var/root
export PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
WORKSPACE="${4%/}"
PREFIX=/usr/local/unity-gateway
NODE_VERSION=22.23.5
NODE_SHA256=89fadefd7798158d8990ca9ed7dbb58f8ca7593adb92fe3da8a445db99415533
UG_REPO=https://github.com/databricks/unity-gateway
UV_URL=https://astral.sh/uv/install.sh
CLI_URL=https://raw.githubusercontent.com
CLI_URL="$CLI_URL/databricks/setup-cli/main/install.sh"
CLT_MARKER=/tmp/.com.apple.dt.CommandLineTools
CLT_MARKER="$CLT_MARKER.installondemand.in-progress"
# ug must be in a shared path: the machine-wide agent settings
# run it by absolute path for every user.
export UV_TOOL_DIR="$PREFIX/tools"
export UV_TOOL_BIN_DIR=/usr/local/bin
export UV_PYTHON_INSTALL_DIR="$PREFIX/python"
export UV_PYTHON_PREFERENCE=only-managed
# ug's npm installer must put agents on every user's PATH, not in root's home.
export npm_config_prefix=/usr/local
mkdir -p /usr/local/bin
# Get ug from git
if ! xcode-select -p >/dev/null 2>&1; then
touch "$CLT_MARKER"
clt="$(softwareupdate -l 2>/dev/null \
| sed -n 's/^\* Label: \(Command Line Tools.*\)$/\1/p' \
| tail -n1)"
softwareupdate -i "$clt"
rm -f "$CLT_MARKER"
fi
if ! command -v uv >/dev/null; then
curl -LsSf "$UV_URL" \
| env UV_INSTALL_DIR=/usr/local/bin UV_NO_MODIFY_PATH=1 sh
fi
uv tool install --force "git+$UG_REPO"
if [ ! -x /usr/local/bin/databricks ]; then
curl -fsSL "$CLI_URL" | sh
fi
# ug configure installs missing agents with npm; provide a shared Node.js runtime.
if ! command -v node >/dev/null || ! command -v npm >/dev/null; then
tmp="$(mktemp -d)"
trap 'rm -rf "$tmp"' EXIT
package="node-v$NODE_VERSION.pkg"
/usr/bin/curl -fsSL -o "$tmp/$package" \
"https://nodejs.org/dist/v$NODE_VERSION/$package"
printf '%s %s\n' "$NODE_SHA256" "$tmp/$package" | /usr/bin/shasum -a 256 -c -
/usr/sbin/installer -pkg "$tmp/$package" -target /
fi
# Get short lived credential; curl reads the client id and secret from
# stdin (-K -) so they don't appear in its arguments.
resp="$(printf 'user = "%s:%s"\n' "$5" "$6" \
| curl -sS -K - \
-d grant_type=client_credentials \
--data-urlencode 'scope=ai-gateway:read unity-catalog:read' \
"$WORKSPACE/oidc/v1/token")"
if ! DATABRICKS_BEARER="$(printf '%s' "$resp" \
| plutil -extract access_token raw -o - -)"; then
echo "Token request to $WORKSPACE failed: $resp" >&2
exit 1
fi
export DATABRICKS_BEARER
/usr/local/bin/ug configure --global --mdm --workspace "$WORKSPACE" \
--agents claude,codex </dev/null
unset DATABRICKS_BEARER resp
# Aliases for every user's interactive zsh and bash shells. The block is
# rewritten on each run, which restores it if a macOS update resets
# the file.
for rc in /etc/zshrc /etc/bashrc; do
[ -f "$rc" ] || continue
sed -i '' '/^# BEGIN unity-gateway/,/^# END unity-gateway/d' "$rc"
cat >>"$rc" <<'ALIASES'
# BEGIN unity-gateway (managed by MDM)
alias claude='UG_SKIP_OS_SETTINGS=1 ug claude'
alias codex='UG_SKIP_OS_SETTINGS=1 ug codex'
# END unity-gateway
ALIASES
done
-
オプション tab で、 パラメーター 4 を
Workspace URL、 パラメーター 5 をClient ID、 パラメーター 6 をClient secretとラベル付けします。![Jamf Proスクリプトの[オプション]tab。パラメーター4には「ワークスペースURL」、パラメーター5には「クライアントID」、パラメーター6には「クライアントシークレット」とラベル付けされています](/gcp/ja/assets/images/coding-agent-rollout-jamf-script-parameters-40b67917130b7c1462b4426a1495a33b.png)
-
保存 をクリックします。
このスクリプトは、ランのたびに ug を再インストールし、Databricks CLI が欠落している場合にのみインストールします。Node.js または npm が見つからない場合、スクリプトは、ピン留めされた SHA-256 チェックサムを確認した後、公式の Node.js 22.23.5 パッケージをインストールします。次に、ug configure は共有 PATH 上の既存のエージェントを再利用するか、Unity Gateway の組み込みインストーラーを使用して npm から Claude Code および Codex をインストールします。ワークスペースが有効にしていないエージェントはインストールされません。それ以外の場合、スクリプトは Node.js、エージェント、または CLI を更新しません。これらを最新の状態に保つには、デバイス上のソフトウェアを更新する方法に合わせてスクリプトを変更してください。
このスクリプトの以前のバージョンでプロビジョニングされたMacでは、ネイティブエージェントのインストールが維持されます。新しいスクリプトを実行しても、npmへの移行にはなりません。これらのMacをnpmに移行するには、ソフトウェア管理プロセスを使用して古いネイティブインストールを削除し、その後ポリシーを再度ランします。
既存のCodexインストールを更新して、Codexのバージョン要件を満たしてください。
ポリシーを作成します
-
コンピュータ > ポリシー > 新規 の順に移動します。
-
全般 で、 Trigger を 定期チェックイン に、 実行頻度 を 1日1回 に設定します。各デバイスは毎日
ug configure --global --mdmを実行し、ワークスペースに公開した構成のアップデートを適用します。
-
「 スクリプト 」で、 優先度 を「 後 」に設定した
Unity Gateway provisionを追加します。パラメーターを入力します:
パラメーター | Value |
|---|---|
4 (ワークスペースURL) |
|
5(クライアント ID) | Service PrincipalのクライアントID。 |
6 (クライアントのシークレット) | Service Principalのシークレット。 |
4. スコープ で、ターゲットにするデバイスを選択します。小さなグループのパイロットデバイスから起動します。
- 保存 をクリックします。Jamf Proは、次回のチェックイン時に、各対象デバイスでポリシーをランします。
このステップでは、Windowsプロビジョニングスクリプトをローカルに保存し、Win32アプリとしてパッケージ化して、1台のデバイスを含むパイロットグループにIntuneを通じて展開する方法を説明します。IntuneはインストーラーをSYSTEMとしてランします。
始める前に
- WindowsデバイスをIntuneに登録する。Windows 11 Pro、Enterprise、またはEducationを使用してください。
- コーディングエージェントの構成を公開する際は、Claude CodeとCodexの両方を有効にし、プロビジョニング用Service Principalがアクセスできるモデルを使用してください。インストーラーは、両方のエージェントがインストールされていることを確認します。
- プロビジョニング用Service Principalを作成を完了し、そのクライアントIDとシークレットを用意してください。
パッケージ作成用コンピュータは、デプロイ先デバイスと異なる場合があります。ターゲットデバイスは、SYSTEMとしてワークスペース、GitHubとそのリリースdownloadホスト、PyPI、nodejs.org、registry.npmjs.orgにネットワークアクセスできる必要があります。
Intune install arguments are not a secure secret channel. The example below passes the provisioning secret as an argument, which can appear in app settings and endpoint management or process logs. Use this form only if your organization's credential policy permits it. Restrict access to the app configuration, use a dedicated short-lived secret, and redact logs before sharing them. Do not embed credentials in the script or package.
If your organization prohibits secret arguments, supply DATABRICKS_CLIENT_SECRET through an approved runtime credential source instead. Intune does not supply that credential source or populate the environment variable automatically.
パッケージを準備してください。
-
パッケージング用コンピュータで、管理者としてWindows PowerShellを開きます。パッケージソース、ツール、出力用のフォルダーを作成します:
PowerShellNew-Item -ItemType Directory -Force -Path C:\UGPackage, C:\UGTools, C:\UGOutput | Out-Null -
メモ帳でローカルファイルを開きます:
PowerShellnotepad C:\UGPackage\windows-provision.ps1 -
次のスクリプトをメモ帳にコピーし、
C:\UGPackage\windows-provision.ps1として保存してから、メモ帳を閉じます。 名前を付けて保存 を使用する場合は、名前が.txtで終わらないように すべてのファイル を選択します。
Windowsプロビジョニングスクリプトを表示する
# Run as SYSTEM or administrator in 64-bit PowerShell.
# Developers sign in with their own Databricks accounts.
[CmdletBinding()]
param(
[string]$Workspace = $env:DATABRICKS_HOST,
[string]$ClientId = $env:DATABRICKS_CLIENT_ID,
[string]$ClientSecret = $env:DATABRICKS_CLIENT_SECRET,
[string]$UgRef = '4504ca99115801f033149dc92d936ed80a2246f9',
[switch]$Uninstall
)
# Check inputs and set shared install locations
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
if (-not [Environment]::Is64BitProcess) { throw 'Run this script in 64-bit PowerShell.' }
$principal = New-Object Security.Principal.WindowsPrincipal(
[Security.Principal.WindowsIdentity]::GetCurrent())
if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
throw 'Run this script as administrator or SYSTEM.'
}
if (-not $Uninstall) {
if (-not $Workspace -or -not $ClientId -or -not $ClientSecret) {
throw 'Supply Workspace, ClientId and ClientSecret as parameters or DATABRICKS_HOST, DATABRICKS_CLIENT_ID and DATABRICKS_CLIENT_SECRET environment variables.'
}
$uri = $null
if (-not [Uri]::TryCreate($Workspace, [UriKind]::Absolute, [ref]$uri) -or
$uri.Scheme -ne 'https' -or $uri.UserInfo -or $uri.Query -or $uri.Fragment -or
$uri.AbsolutePath -ne '/') { throw 'Workspace must be an https:// workspace origin.' }
if (-not $UgRef) { throw 'Supply a ug release tag or commit with -UgRef.' }
$Workspace = $Workspace.TrimEnd('/')
}
$nativeArch = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment').PROCESSOR_ARCHITECTURE
if ($nativeArch -notin 'ARM64', 'AMD64') { throw "Unsupported architecture: $nativeArch" }
$Arm = $nativeArch -eq 'ARM64'
$Prefix = Join-Path $env:ProgramW6432 'UnityGateway'
$BinDir = Join-Path $Prefix 'bin'
$NodeDir = Join-Path $Prefix 'node'
$NpmDir = Join-Path $Prefix 'npm'
$NodeReleases = 'https://nodejs.org/dist'
$CliReleases = 'https://github.com/databricks/cli/releases/download'
$CliVersionUrl = 'https://raw.githubusercontent.com/databricks/setup-cli/main/VERSION'
$UgRepo = 'https://github.com/databricks/unity-gateway'
$GitVersion = '2.56.0.windows.4'
$UvVersion = '0.13.7'
$GitHashes = @{
AMD64 = '4961a4a8cc778d8b6e00a5819e5fe4d078b754555aff7aedc2d77a5d74c2de80'
ARM64 = 'e7dcc4adbb0eb373064598cd18bc75e60128707d816ead51cd9bd98e356f0075'
}
$UvHashes = @{
AMD64 = '0cdc5b38fe5a8168ed6a25814f5ba43c21d313dd3187314fccb37b7cec46e021'
ARM64 = '505d9e65e7692bac3ddf98c66754aa26c5050c409c184af30a881a0a72cc85e3'
}
$env:PYTHONUTF8 = '1'
$env:UV_TOOL_DIR = Join-Path $Prefix 'tools'
$env:UV_TOOL_BIN_DIR = $BinDir
$env:UV_PYTHON_INSTALL_DIR = Join-Path $Prefix 'python'
$env:UV_PYTHON_PREFERENCE = 'only-managed'
# Copies, not cache hard links, so installed files inherit Program Files' read access for users.
$env:UV_LINK_MODE = 'copy'
$env:npm_config_prefix = $NpmDir
# Download, checksum, PATH and profile helpers
function Get-File($Url, $OutFile) {
Invoke-WebRequest -UseBasicParsing -Uri $Url -OutFile $OutFile
}
function Get-Text($Url) {
$file = Join-Path $Tmp ([guid]::NewGuid())
Get-File $Url $file
(Get-Content -Raw -LiteralPath $file).Trim()
}
function Assert-Sha256($Path, $Expected) {
if ($Expected -notmatch '^[a-fA-F0-9]{64}$' -or
(Get-FileHash -Algorithm SHA256 -LiteralPath $Path).Hash -ne $Expected) {
throw "Checksum mismatch or missing SHA256 for $Path"
}
}
function Get-Sha256Sum($SumsFile, $Name) {
foreach ($line in Get-Content -LiteralPath $SumsFile) {
$parts = $line -split '\s+', 2
if ($parts.Count -eq 2 -and $parts[1].TrimStart('*') -eq $Name) { return $parts[0] }
}
throw "No checksum for $Name"
}
function Update-PathEntry($Path, $Dir, [switch]$Remove) {
if ($Remove) { return (($Path -split ';' | Where-Object { $_ -ne $Dir }) -join ';') }
if (($Path -split ';') -contains $Dir) { return $Path }
return ($Path.TrimEnd(';') + ';' + $Dir).TrimStart(';')
}
function Set-MachinePath($Dir, [switch]$Remove) {
$key = [Microsoft.Win32.Registry]::LocalMachine.OpenSubKey(
'SYSTEM\CurrentControlSet\Control\Session Manager\Environment', $true)
try {
$path = $key.GetValue('Path', '', [Microsoft.Win32.RegistryValueOptions]::DoNotExpandEnvironmentNames)
$kind = $key.GetValueKind('Path')
$updated = Update-PathEntry $path $Dir -Remove:$Remove
if ($updated -ne $path) { $key.SetValue('Path', $updated, $kind) }
} finally { if ($key) { $key.Dispose() } }
$env:Path = Update-PathEntry $env:Path $Dir -Remove:$Remove
}
function Set-SharedReadAccess($Dir) {
if (-not (Test-Path -LiteralPath $Dir -PathType Container)) { throw "Shared runtime folder not found: $Dir" }
foreach ($permission in '*S-1-5-32-545:(OI)(CI)RX', '*S-1-5-32-545:RX') {
& "$env:SystemRoot\System32\icacls.exe" $Dir /grant $permission /T /Q
if ($LASTEXITCODE -ne 0) { throw "Setting shared runtime permissions failed: $LASTEXITCODE" }
}
}
function Get-AgentAliases($Ug) {
$escaped = $Ug.Replace("'", "''")
@"
# BEGIN unity-gateway
function claude {
`$previous = `$env:UG_SKIP_OS_SETTINGS
try { `$env:UG_SKIP_OS_SETTINGS = '1'; & '$escaped' claude @args }
finally { `$env:UG_SKIP_OS_SETTINGS = `$previous }
}
function codex {
`$previous = `$env:UG_SKIP_OS_SETTINGS
try { `$env:UG_SKIP_OS_SETTINGS = '1'; & '$escaped' codex @args }
finally { `$env:UG_SKIP_OS_SETTINGS = `$previous }
}
# END unity-gateway
"@
}
function Update-AgentProfile($Text, $Block) {
$text = "$Text" -replace '(?s)# BEGIN unity-gateway.*?# END unity-gateway\r?\n?', ''
if (-not $Block) { return $text.TrimEnd() }
($text.TrimEnd() + "`r`n" + $Block).TrimStart()
}
$profiles = @("$env:SystemRoot\System32\WindowsPowerShell\v1.0\profile.ps1")
$pwsh7 = Join-Path $env:ProgramW6432 'PowerShell\7'
if (Test-Path -LiteralPath $pwsh7) { $profiles += Join-Path $pwsh7 'profile.ps1' }
# Remove this deployment; leave shared Git and execution policy alone
if ($Uninstall) {
$ug = Join-Path $BinDir 'ug.exe'
if (-not (Test-Path -LiteralPath $ug)) { throw 'ug is missing; repair the installation before uninstalling.' }
$previousSkip = $env:UG_SKIP_OS_SETTINGS
try {
$env:UG_SKIP_OS_SETTINGS = $null
$null | & $ug revert
if ($LASTEXITCODE -ne 0) { throw "ug revert failed: $LASTEXITCODE" }
} finally { $env:UG_SKIP_OS_SETTINGS = $previousSkip }
foreach ($path in $profiles) {
if (Test-Path -LiteralPath $path) {
$text = Get-Content -Raw -LiteralPath $path
Set-Content -LiteralPath $path -Encoding UTF8 -Value (Update-AgentProfile $text '')
}
}
foreach ($dir in $BinDir, $NpmDir, $NodeDir) { Set-MachinePath $dir -Remove }
Remove-Item -Recurse -Force -LiteralPath $Prefix
Write-Output 'Unity Gateway deployment removed. Shared Git and execution policy were left unchanged.'
return
}
New-Item -ItemType Directory -Force -Path $BinDir, $NpmDir | Out-Null
Set-MachinePath $BinDir
Set-MachinePath $NpmDir
$Tmp = Join-Path $Prefix ".tmp-$([guid]::NewGuid())"
New-Item -ItemType Directory -Path $Tmp | Out-Null
try {
# Install Git
if (-not (Get-Command git.exe -ErrorAction SilentlyContinue)) {
$suffix = if ($Arm) { 'arm64' } else { '64-bit' }
$name = "Git-2.56.0.4-$suffix.exe"
$setup = Join-Path $Tmp $name
Get-File "https://github.com/git-for-windows/git/releases/download/v$GitVersion/$name" $setup
Assert-Sha256 $setup $GitHashes[$nativeArch]
$proc = Start-Process -FilePath $setup -Wait -PassThru `
-ArgumentList '/VERYSILENT', '/ALLUSERS', '/NORESTART', '/SUPPRESSMSGBOXES', '/SP-'
if ($proc.ExitCode -ne 0) { throw "Git setup failed: $($proc.ExitCode)" }
Set-MachinePath (Join-Path $env:ProgramW6432 'Git\cmd')
}
# Install uv and ug
$uv = Join-Path $BinDir 'uv.exe'
if (-not (Test-Path -LiteralPath $uv)) {
$target = if ($Arm) { 'aarch64-pc-windows-msvc' } else { 'x86_64-pc-windows-msvc' }
$zip = Join-Path $Tmp 'uv.zip'
Get-File "https://github.com/astral-sh/uv/releases/download/$UvVersion/uv-$target.zip" $zip
Assert-Sha256 $zip $UvHashes[$nativeArch]
Expand-Archive -LiteralPath $zip -DestinationPath (Join-Path $Tmp 'uv')
Copy-Item (Join-Path $Tmp 'uv\uv.exe') $BinDir
}
& $uv tool install --force --python cpython-3.13-windows-x86_64-none "git+$UgRepo@$UgRef"
if ($LASTEXITCODE -ne 0) { throw "uv tool install failed: $LASTEXITCODE" }
# Install the Databricks CLI
if (-not (Test-Path -LiteralPath (Join-Path $BinDir 'databricks.exe'))) {
$version = Get-Text $CliVersionUrl
$arch = if ($Arm) { 'arm64' } else { 'amd64' }
$zip = "databricks_cli_${version}_windows_$arch.zip"
$base = "$CliReleases/v$version"
Get-File "$base/$zip" (Join-Path $Tmp $zip)
Get-File "$base/databricks_cli_${version}_SHA256SUMS" (Join-Path $Tmp 'cli-sums')
Assert-Sha256 (Join-Path $Tmp $zip) (Get-Sha256Sum (Join-Path $Tmp 'cli-sums') $zip)
Expand-Archive -LiteralPath (Join-Path $Tmp $zip) -DestinationPath (Join-Path $Tmp 'cli')
Copy-Item (Join-Path $Tmp 'cli\databricks.exe') $BinDir
}
# Install Node.js for ug's npm agent installer
if (-not (Test-Path -LiteralPath (Join-Path $NodeDir 'npm.cmd'))) {
$releases = Invoke-RestMethod -UseBasicParsing -Uri "$NodeReleases/index.json"
$version = ($releases | Where-Object { $_.lts } | Select-Object -First 1).version
if ($version -notmatch '^v\d+\.\d+\.\d+$') { throw 'No valid Node.js LTS release found.' }
$name = "node-$version-win-$(if ($Arm) { 'arm64' } else { 'x64' })"
Get-File "$NodeReleases/$version/$name.zip" (Join-Path $Tmp "$name.zip")
Get-File "$NodeReleases/$version/SHASUMS256.txt" (Join-Path $Tmp 'node-sums')
Assert-Sha256 (Join-Path $Tmp "$name.zip") (Get-Sha256Sum (Join-Path $Tmp 'node-sums') "$name.zip")
Expand-Archive -LiteralPath (Join-Path $Tmp "$name.zip") -DestinationPath $Tmp
New-Item -ItemType Directory -Force -Path $NodeDir | Out-Null
Copy-Item (Join-Path $Tmp "$name\*") $NodeDir -Recurse -Force
}
Set-MachinePath $NodeDir
} finally {
Remove-Item -Recurse -Force -LiteralPath $Tmp -ErrorAction SilentlyContinue
}
# Get a provisioning token and configure agents with ug's npm fallback
$previousBearer = $env:DATABRICKS_BEARER
$previousSkip = $env:UG_SKIP_OS_SETTINGS
try {
$basic = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes("${ClientId}:${ClientSecret}"))
$resp = Invoke-RestMethod -UseBasicParsing -Method Post `
-Uri "$Workspace/oidc/v1/token" -Headers @{ Authorization = "Basic $basic" } `
-ContentType 'application/x-www-form-urlencoded' `
-Body @{ grant_type = 'client_credentials'; scope = 'ai-gateway:read unity-catalog:read' }
if (-not $resp.access_token) { throw 'Token request returned no access_token.' }
$env:DATABRICKS_BEARER = $resp.access_token
$env:UG_SKIP_OS_SETTINGS = $null
$null | & (Join-Path $BinDir 'ug.exe') configure --global --mdm --workspace $Workspace --agents claude,codex
if ($LASTEXITCODE -ne 0) { throw "ug configure failed: $LASTEXITCODE" }
} finally {
$env:DATABRICKS_BEARER = $previousBearer
$env:UG_SKIP_OS_SETTINGS = $previousSkip
$ClientSecret = $null
$basic = $null
$resp = $null
}
foreach ($name in 'claude', 'codex') {
if (-not (Test-Path -LiteralPath (Join-Path $NpmDir "$name.cmd"))) {
throw "$name was not installed in $NpmDir. Check ug configure's output."
}
}
# Allow standard users to read and run the shared installation
Set-SharedReadAccess $Prefix
# Add PowerShell aliases for all users
if ((Get-ExecutionPolicy -Scope LocalMachine) -in 'Undefined', 'Restricted') {
try { Set-ExecutionPolicy -Scope LocalMachine RemoteSigned -Force }
catch { if ($_.FullyQualifiedErrorId -notlike 'ExecutionPolicyOverride*') { throw } }
}
foreach ($scope in 'MachinePolicy', 'UserPolicy', 'LocalMachine') {
if ((Get-ExecutionPolicy -Scope $scope) -in 'AllSigned', 'Restricted') {
Write-Warning "$scope execution policy may prevent the PowerShell aliases from loading."
}
}
$block = Get-AgentAliases (Join-Path $BinDir 'ug.exe')
foreach ($path in $profiles) {
$text = if (Test-Path -LiteralPath $path) { Get-Content -Raw -LiteralPath $path } else { '' }
Set-Content -LiteralPath $path -Encoding UTF8 -Value (Update-AgentProfile $text $block)
}
# Record a completed deployment and keep the script for Intune uninstall
$scriptHash = (Get-FileHash -Algorithm SHA256 -LiteralPath $PSCommandPath).Hash
$installedScript = Join-Path $Prefix 'windows-provision.ps1'
if ([IO.Path]::GetFullPath($PSCommandPath) -ne [IO.Path]::GetFullPath($installedScript)) {
Copy-Item -LiteralPath $PSCommandPath -Destination $installedScript -Force
}
@{
workspace = $Workspace
ugRef = $UgRef
scriptSha256 = $scriptHash
} | ConvertTo-Json | Set-Content -LiteralPath (Join-Path $Prefix 'provisioned.json') -Encoding UTF8
Write-Output 'Unity Gateway provisioning completed.'
資格情報の入力欄は変更しないでください。後でIntuneアプリの設定に、ワークスペースのURL、クライアントID、シークレットを入力します。スクリプトには、標準ユーザー向けの共有ランタイムの権限修復が含まれています。Intuneの配信をテストする前に、手動でランしないでください。
4. SYSTEMからパブリックパッケージレジストリにアクセスできない場合は、パッケージ化する前に、$ErrorActionPreference = 'Stop'の下、スクリプトのparam(...)ブロックの後に、承認済みのミラー設定を追加してください:
$env:UV_DEFAULT_INDEX = 'https://<approved-pypi-host>/simple'
$env:npm_config_registry = 'https://<approved-npm-host>/'
パブリックレジストリにアクセスできる場合は、これらの行を省略してください。パッケージにプロキシのパスワードを含めないでください。
5. MicrosoftのWin32 Content Prep Toolをdownloadし、IntuneWinAppUtil.exeをC:\UGToolsの下に保存してください。ソースフォルダーはwindows-provision.ps1に限定してください。パッケージをビルドします:
& C:\UGTools\IntuneWinAppUtil.exe -c C:\UGPackage -s windows-provision.ps1 -o C:\UGOutput -q
if ($LASTEXITCODE -ne 0) { throw "Packaging failed: $LASTEXITCODE" }
Get-Item C:\UGOutput\windows-provision.intunewin
出力はC:\UGOutput\windows-provision.intunewinです。必要に応じて、このファイルをIntuneを開く際に使用するコンピュータに転送してください。
パイロットデバイスグループとアプリを作成します
- Intune管理センターで、 デバイス > すべてのデバイス を開き、テストデバイスの名前をメモします。
- メインナビゲーションで、 グループ > すべてのグループ > 新しいグループ を開いてください。グループの種類に セキュリティ 、メンバーシップに 割り当て済み を選択し、名前を
Unity Gateway Windows pilotにします。対象デバイスのみを追加してください。 - アプリ>すべてのアプリ>作成 を開き、 Windowsアプリ(Win32) を選択して、
windows-provision.intunewinをuploadします。 - アプリ情報 で、名前に
Unity Gateway Windows pilot、発行元にDatabricksを入力します。 次へ をクリックします。
インストールコマンドを設定してください。
Intune管理センターで、 プログラム ページにあるWin32アプリの構成を続けます。Intuneがアプリのインストールと削除に使用するコマンドを入力します。
スクリプトは共有ツールをC:\Program Files\UnityGatewayの下にインストールし、標準ユーザーに読み取り/ランアクセスを付与して、ug configure --global --mdmをランします。PowerShellの起動関数が追加され、未設定またはRestrictedのLocalMachine実行ポリシーがRemoteSignedに変更されます。グループポリシーを上書きすることはありません。割り当てる前に、これらの変更がデバイスポリシーに適合していることを確認してください。
-
インストーラーの種類を選択する項目が表示された場合は、 コマンド ライン を選択します。
-
インストールコマンド に、次のコマンドを貼り付けます。
<workspace-url>、<client-id>、<client-secret>を置き換えます。完全なhttps://ワークスペースのオリジンを使用し、末尾にパスを付けないでください:TextC:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File ".\windows-provision.ps1" -Workspace "<workspace-url>" -ClientId "<client-id>" -ClientSecret "<client-secret>" -UgRef "main"このコマンドは、
mainからUnity Gatewayをインストールします。代わりにバージョンをピン留めするには、-UgRefにcommit SHAまたはタグを渡し、パッケージを準備する際に、その参照元のwindows-provision.ps1スクリプトを使用します。内容が入力されたコマンドをターミナルに貼り付けたり、スクリーンショットに含めたりしないでください。
-
アンインストール コマンド に次を入力します:
TextC:\Windows\Sysnative\WindowsPowerShell\v1.0\powershell.exe -NoProfile -ExecutionPolicy Bypass -File "C:\Program Files\UnityGateway\windows-provision.ps1" -Uninstallコマンドは、Windowsが
C:にインストールされていることを前提としています。他のインストール先ドライブのパスを調整します。アンインストールフィールドでは環境変数は展開されません。32ビットのIntune管理プロセスがインストーラーを起動するとき、Sysnativeによって64ビット版のPowerShellが選択されます。 -
残りのProgramオプションを設定します:
設定
Value
インストールの動作
システム
インストールに必要な時間
60分
デバイスの再起動動作
特定の操作なし
利用可能なアンインストールを許可する
パイロット期間中に表示された場合は いいえ
戻りコード
Defaults
-
次へ をクリックします。
要件、検出、割り当てを設定する
Intune管理センターで、Win32アプリのウィザードの残りのページを進めます。これらの設定では、アプリをインストールできるデバイス、Intuneがインストール完了を検出する方法、およびアプリを受け取るパイロットグループを定義します。
-
「 要件 」で、対象アーキテクチャ(x64またはARM64が表示されている場合)と、テストデバイスが満たすWindows 11の最小バージョンを選択します。パイロットでは、オプションのリソース要件を未設定のままにします。
-
「 検出ルール 」では、 検出ルールを手動で構成 > 追加 > ファイル を選択します:
フィールド
Value
パス
C:\Program Files\UnityGatewayファイルまたはフォルダー
provisioned.json検出方法
ファイルまたはフォルダーが存在します
64ビットクライアント上の32ビットアプリに関連付けられた
No
構成、ランタイムのアクセス許可の修復、プロファイルの設定が完了すると、スクリプトはマーカーを書き込みます。以前のインストールでファイルが存在している場合、Intuneは新しいパッケージを実行せずにインストール済みと報告することがあります。初回の配信テストには、クリーンな登録済みテストデバイスを使用してください。
-
このパイロットでは、 依存関係 にも 置き換え にも何も追加しないでください。スクリプトは独自の依存関係をインストールします。
-
割り当て で、 必須 の下に Unity Gateway Windows pilot を追加してください。 使用可能 と アンインストール は空欄のままにし、 すべてのユーザー または すべてのデバイス には割り当てないでください。
-
概要を確認し、 作成 をクリックします。
同期してインストールを確認する
-
デバイス > すべてのデバイス > 対象のデバイス > 同期 を開きます。デバイスをオンラインの状態に保ちます。
-
Syncペインだけでなく、 アプリ > すべてのアプリ > Unity Gateway Windows pilot > デバイスのインストール状態 を監視してください。同期によってチェックインが要求されますが、インストールと報告にはさらに時間がかかる場合があります。
-
アプリに Installed と表示されたら、対象デバイスを確認します:
PowerShellTest-Path 'C:\Program Files\UnityGateway\provisioned.json'Get-Content 'C:\Program Files\UnityGateway\provisioned.json'Trueと、ワークスペースURLおよび要求されたugRefを含むマーカーが表示されます。この例では、ugRefは解決済みのcommitではなく、文字どおりのBranch名mainです。 -
開発者がPowerShellを開く前に、Windowsを再起動するか、サインアウトして再度サインインしてください。既存のターミナルには古いPATHが残っていることがあり、CodexのnpmランチャーがNode.jsを見つけられない原因になります。
-
通常の非管理者Windows PowerShellセッションで、コマンドの解決状況を確認します:
PowerShellGet-Command ug, node, claude, codex | Select-Object Name, Source, CommandTypeProgram Filesの下に
ugとnode、Functionコマンドタイプではclaude/codexがあることを想定してください。開発者としてサインインした後、各エージェントを個別にランし、プロンプトを完了します。復旧用の管理者は別に確保してください。唯一の管理者を降格させることは前提条件ではありません。
インストールに失敗した場合は、C:\ProgramData\Microsoft\IntuneManagementExtension\Logsの下にあるAppWorkload.logとAppActionProcessor.logを確認してください。Logsには、シークレットを含むインストールコマンドが含まれていることがあります。抜粋を共有する前に、認証情報とトークンを伏せてください。0x80070001として報告された1のインストーラー終了コードは汎用的なものであり、根本原因となるスクリプトエラーを特定するものではありません。
uvがインストールされているもののugが見つからない場合は、SYSTEMコンテキストでのGit/PyPIへのアクセスと、承認済みのレジストリ設定を確認してください。設定が変更された場合は、パッケージを再ビルドしてuploadしてください。終了コード1を成功にマッピングしないでください。組織のポリシーによってブロックされているプロファイルでは、ポリシーをオーバーライドする代わりに、$env:UG_SKIP_OS_SETTINGS = '1'; ug claudeまたはug codexを直接使用してください。
ソフトウェアの更新には、バージョンを考慮した検出と置き換えに対応する改訂版パッケージを使用してください。上記のマーカー存在ルールは初期パイロット用であり、構成の更新はスケジュールしません。削除する場合は、アンインストールを割り当てる前に必須の割り当てを削除してください。スクリプトは、ランタイムブロックとプロファイルブロックを削除する前にug revertを実行します。共有Git、実行ポリシー、および開発者のDatabricks認証情報は変更しません。
開発者に伝える
プロビジョニングが完了したら、開発者は新しいターミナルでclaudeまたはcodexをランします。Windowsでは、まず再起動するか、サインアウトして再度サインインし、マシンのPATHを更新します。macOSのプロビジョニングスクリプト内のエイリアスは、ug claudeまたはug codexを起動します。初回起動時に、開発者はDatabricksにサインインし、ugユーザーレベルのMCPサーバーとスキルを設定します。コーディングエージェントのアクティビティは、その開発者に帰属します。
開発者は、最初にugを起動した後、エージェント独自のコマンドをランすることもできます。マシン全体の設定では、引き続きモデルリクエストがゲートウェイ経由でルーティングされます。モデルの検出、トレース、Smart Routingには、ugの起動が必要です。
Claude デスクトップ版のロールアウト
macOSとWindowsでは、ug configure --globalはデバイス上のすべてのユーザー向けにClaudeデスクトップアプリも設定します。プロビジョニングスクリプトがランされる前にClaude desktopをインストールしてくださいug configure --global上記のJamf ProおよびIntuneのスクリプトでは、Claudeデスクトップはインストールされません。
ユーザーが初めてClaude Desktopを開くと、自身のDatabricksアカウントでサインインします。ユーザーはclaude.aiのプロジェクトやチャットをインポートすることもできます。
ロールアウトの検証
パイロットデバイスで、開発者のオペレーティングシステムのログインアカウントでサインインし、次のことを確認します:
ug statusレポートMachine-wide settings: From the published agent configuration。- エージェントが開き、構成されたモデルを使用して応答します。
- 構成されたMCPサーバーとスキルが利用可能になり、開発者はそれらを使用できます。
- リクエストは Unity Gateway の使用状況追跡に表示され、トレースが有効になっている場合はトレースも表示されます。コーディングエージェントのアクティビティの監視を参照してください。
プロビジョニングスクリプトまたは公開済み構成を変更した後、これらのチェックを繰り返してください。
資格情報と設定の維持
Service Principalのシークレットをローテーションするには:
-
Service Principal の新しいシークレットを生成します。
-
デプロイ設定でシークレットを更新してください:
- macOSでは、MDMポリシーのパラメーターを更新してください。
- Intuneでは、 アプリ > すべてのアプリ > Unity Gateway Windows pilot > プロパティ > プログラム > 編集 を開き、 インストールコマンド の
-ClientSecret引数を置き換えます。変更を保存してください。代わりにランタイムの認証情報ソースを使用する場合は、そこでシークレットを更新してください。
-
古いシークレットを削除する前に、新しいシークレットを使用してパイロットデバイスでプロビジョニングのランを実行します。
シークレットが漏洩した場合は、直ちにローテーションを行い、古いシークレットを削除してください。スクリプトがリクエストするトークンは短命であり、スクリプトはデバイスにトークンを書き込まないため、デバイスごとに取り消す必要がある認証情報はありません。
Intuneのインストールコマンドを変更しても、インストール済みとして検出されたデバイスでプロビジョニングが再実行されることはありません。新しいシークレットは、その後のインストールや修復、または明示的にスケジュールされたプロビジョニングのランに使用されます。既存の開発者セッションではそれぞれ独自のOAuthが使用されるため、プロビジョニングシークレットは必要ありません。すでにインストールされているデバイスでローテーションをテストするには、パイロットの例にあるマーカーの存在ルールではなく、バージョンを認識する検出を使用するデプロイのリビジョンを使用します。
構成を更新するには、ワークスペースで変更を公開し、プロビジョニングを再度スケジュールしてください。ポリシーまたはインストーラーのラン時に、デバイスに変更が適用されます。各ug configure --globalランでは、公開済みの構成からマシン全体のファイルが再構築されるため、削除した設定はなくなり、ファイルへの手動編集は置き換えられます。--globalでプロビジョニングされたデバイスでは、開発者のug configureやエージェントの起動によって、マシン全体のファイルは変更されません。アプリがインストール済みと報告されている間、Intuneのマーカー存在検出では更新はTriggerされません。
デバイスが公開済みの構成をすでに受け取っている場合、ワークスペースから構成を削除しても、デバイス全体に適用される設定は削除されません。後続のug configure --globalは終了コード5で終了し、ファイルを保持します。これらを意図的に削除するには、rootとしてug revertをランします。コマンドオプションについては、ug CLI referenceを参照してください。
トラブルシューティング
エラー | 原因 |
|---|---|
| MDMポリシーのクライアントIDまたはシークレットが間違っているか、シークレットの有効期限が切れています。 |
| シークレットには |
| 有効なエージェントには、例えばClaudeモデルなしで構成されたClaude Codeなど、Service Principalが使用できるモデルがありません。 |
WindowsのCoworkで、Claude Desktopに 追加のセットアップが必要です と表示されます。 | Windows仮想マシンプラットフォーム機能が有効になっていません。 |