📲
Windows で最新の Okta Verify をインストールするスクリプトを作った(Intuneの利用を想定)
これは何?
Microsoft Intune にて任意のアプリケーションを再アップロードせずに最新のバージョンで展開する方法の派生記事です。
ここでは iDaaS の Okta でデスクトップ認証や生体認証で利用できる「Okta Verify」を Intune への再アップロード不要で常に最新バージョンを展開する方法を紹介します。
Intune周りの設定方法について
ここと同じなので重複するところは触れません。
実現する仕組みについて
Windows 用の Okta Verify インストーラーは Okta の管理画面でのみ入手可能で、それ以外(Microsoft Store や winget コマンド)の方法では入手できません。
しかし、実はOkta管理画面にリンクされている配布URLは認証なしで誰でもアクセス可能です。ここから誰でも入手できるので、この仕組みを使って Windows 端末実機から直接インストーラーを取得してもらいます。
スクリプト
16行目で $url
の変数定義で書かれている <YOUR_ORGANIZATION>
の箇所だけお使いの Okta テナントに合わせて上書きしてください。
ファイル名は oktaVerifyInstall.ps1
とします。
#
# Ref
# https://help.okta.com/oie/ja-jp/content/topics/identity-engine/devices/ov-install-options-windows.htm
# https://help.okta.com/oie/ja-jp/content/topics/identity-engine/devices/ov-win-config-vdi.htm
#
param(
[string]$oktaUrl = "",
[switch]$windows365 = $false,
[switch]$awsworkspaces = $false,
[switch]$uninstall = $false,
[switch]$isDebug = $false
)
$installer = "OktaVerifySetup.exe"
$label = "OktaVerify"
$url = "https://<YOUR_ORGANIZATION>-admin.okta.com/api/v1/artifacts/WINDOWS_OKTA_VERIFY/download?releaseChannel=GA"
$testPath = "C:\Program Files\Okta\Okta Verify\OktaVerify.exe"
$maxWaitTime = 120
function checkInstallPath($exist) {
for($i = 0; $i -lt $maxWaitTime; $i++){
if((Test-Path $testPath) -eq $exist){
# break でループを終了します。
break
}
Start-Sleep -Seconds 1
}
# 30秒ほど待機いれないとエラーになる
Start-Sleep -Seconds 30
}
If($windows365 -and $awsworkspaces){
echo "-windows365 と -awsworkspaces は同時に指定できません。"
exit 1
}
if (!$isDebug){
$ProgressPreference = "SilentlyContinue"
}
if ($uninstall)
{
$productId32bit = (Get-ChildItem -Path "Registry::HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object DisplayName -like "$label*" | Select-Object -ExpandProperty PSChildName)
$productId64bit = (Get-ChildItem -Path "Registry::HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall" | Get-ItemProperty | Where-Object DisplayName -like "$label*" | Select-Object -ExpandProperty PSChildName)
if ($productId32bit -eq "" -and $productId64bit -eq ""){
echo "レジストリにアプリケーションが登録されていません。"
exit 1
}
$productId = ""
if (!($productId32bit -ne "" -or $productId64bit -ne "")){
echo "32bit と 64bit 両方にアプリケーションが登録されています。64bit を優先します。"
$productId = $productId64bit
}else{
$productId = (echo $productId32bit$productId64bit)
}
Start-Process -FilePath "msiexec" -ArgumentList "/x", $productId, "/qn"
# インストーラを起動すると非同期で処理されてしまうため、インストール完了よりも先に本スクリプトが完了してしまう恐れがある
# 先に終了してしまうと Intune の完了検知にて誤作動を起こしてしまうため一定時間スリープする
checkInstallPath $false
exit 0
}
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile $installer
if($windows365){
Start-Process -FilePath ".\$installer" -ArgumentList "/q", "OrgUrl=$oktaUrl", "AuthenticatorOperationMode=VirtualDesktopStatic"
}elseif($awsworkspaces){
Start-Process -FilePath ".\$installer" -ArgumentList "/q", "OrgUrl=$oktaUrl", "AuthenticatorOperationMode=VirtualDesktopLayered"
}else{
Start-Process -FilePath ".\$installer" -ArgumentList "/q", "OrgUrl=$oktaUrl"
}
# インストーラを起動すると非同期で処理されてしまうため、インストール完了よりも先に本スクリプトが完了してしまう恐れがある
# 先に終了してしまうと Intune の完了検知にて誤作動を起こしてしまうため一定時間スリープする
checkInstallPath $true
スクリプトの呼び出し方法
展開する環境によって異なるので以下の表を参考にしてみてください。
<YOUR_ORGANIZATION>
はお使いの Okta テナントに合わせて上書きしてください。
展開先・用途 | 呼び出しコマンド |
---|---|
Windows 実機へインストール | powershell -ExecutionPolicy Bypass -windowstyle hidden ".\oktaVerifyInstall.ps1 https://<YOUR_ORGANIZATION>.okta.com" |
Microsoft365 仮想環境へのインストール | powershell -ExecutionPolicy Bypass -windowstyle hidden ".\oktaVerifyInstall.ps1 https://<YOUR_ORGANIZATION>.okta.com -windows365" |
AWS Workspace 仮想環境へのインストール | powershell -ExecutionPolicy Bypass -windowstyle hidden ".\oktaVerifyInstall.ps1 https://<YOUR_ORGANIZATION>.okta.com -awsworkspaces" |
アンインストール | powershell -ExecutionPolicy Bypass -windowstyle hidden ".\oktaVerifyInstall.ps1 -uninstall" |
Discussion