Azure 虚拟桌面:会话主机单独配置FSLogix

1. 概述

会有一些场景,你不太方便在AD上通过组策略下发的方式让他们配置FSLogix,所以通过这种方式可以简单,简洁的每一台虚拟机上去运行来搞,只是不太适合一些策略缩放的场景,会话主机很多的话管理也很麻烦。

2. 步骤

完整的实战在我的文章《Azure虚拟桌面实战指南:从需求分析到部署实施》,这篇文章的话是对其的一个补充,主要是讲常规流程。

走以下流程搭建完,就可以直接做FSLOGIX安装了,省去组策略下发
AD域搭建
创建共享主机池
创建存储账户
创建文件共享
文件共享启用AD身份验证
分配文件共享访问权限
创建主机池和主机

在主机池里面

  1. 点击会话主机
  2. 找到 avd 的会话主机
  3. 左侧导航栏,找到操作,运行命令,跑powershel脚本
# 定义变量
$storageAccountName = "存储账户名"  # 替换为你的存储账号名
$fileshareName = "文件共享名称"  # 替换为你的文件共享名
$LabFilesDirectory = "C:\LabFiles"  # 替换为你的本地目录(如果需要)
$fsLogixUrl = "https://experienceazure.blob.core.windows.net/templates/wvd/FSLogix_Apps_Installation.zip"
$fsLogixZipPath = "$LabFilesDirectory\FSLogix_Apps_Installation.zip"
$fsLogixExtractPath = "$LabFilesDirectory\FSLogix"
$azureRegion = "global"  # "global" 或 "china",根据实际情况进行调整

# 根据区域设置文件共享域名
if ($azureRegion -eq "china") {
    $fileShareDomain = "file.core.chinacloudapi.cn"
} else {
    $fileShareDomain = "file.core.windows.net"
}

# 创建目录的函数
function Create-DirectoryIfNotExists {
    param (
        [string]$path
    )
    if (!(Test-Path -Path $path)) {
        New-Item -Path $path -ItemType Directory | Out-Null
    }
}

# 下载FSLogix安装包的函数
function Download-FSLogix {
    param (
        [string]$url,
        [string]$outputPath
    )
    if (!(Test-Path -Path $outputPath)) {
        Invoke-WebRequest -Uri $url -OutFile $outputPath
    }
}

# 解压ZIP文件的函数
function Expand-ZIPFile {
    param (
        [string]$file,
        [string]$destination
    )
    $shell = New-Object -ComObject shell.application
    $zip = $shell.NameSpace($file)
    foreach ($item in $zip.items()) {
        $shell.Namespace($destination).copyhere($item)
    }
}

# 安装FSLogix的函数
function Install-FSLogix {
    param (
        [string]$setupPath
    )
    if (!(Get-WmiObject -Class Win32_Product | Where-Object { $_.Vendor -eq "FSLogix, Inc." })) {
        Start-Process -FilePath $setupPath -ArgumentList "/quiet /install" -Wait
    }
}

# 创建注册表键并添加值的函数
function Set-RegistryValues {
    param (
        [string]$registryPath,
        [string]$vhdLocations
    )
    if (!(Test-Path $registryPath)) {
        New-Item -Path $registryPath -Force | Out-Null
    }

    New-ItemProperty -Path $registryPath -Name "VHDLocations" -Value $vhdLocations -PropertyType String -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name "Enabled" -Value 1 -PropertyType DWord -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name "DeleteLocalProfileWhenVHDShouldApply" -Value 1 -PropertyType DWord -Force | Out-Null
    New-ItemProperty -Path $registryPath -Name "FlipFlopProfileDirectoryName" -Value 1 -PropertyType DWord -Force | Out-Null
}

# 执行脚本
try {
    Write-Host "Creating directories..."
    Create-DirectoryIfNotExists -path $LabFilesDirectory
    Create-DirectoryIfNotExists -path $fsLogixExtractPath

    Write-Host "Downloading FSLogix installation bundle..."
    Download-FSLogix -url $fsLogixUrl -outputPath $fsLogixZipPath

    Write-Host "Extracting FSLogix installation bundle..."
    Expand-ZIPFile -file $fsLogixZipPath -destination $fsLogixExtractPath

    Write-Host "Installing FSLogix..."
    Install-FSLogix -setupPath "$fsLogixExtractPath\x64\Release\FSLogixAppsSetup.exe"

    Write-Host "Setting registry values..."
    $vhdLocations = "\\$storageAccountName.$fileShareDomain\$fileshareName"
    Set-RegistryValues -registryPath "HKLM:\SOFTWARE\FSLogix\Profiles" -vhdLocations $vhdLocations

    Write-Host "Script executed successfully"
} catch {
    Write-Error "An error occurred: $_"
}

脚本运行成功示例:

Creating directories...
Downloading FSLogix installation bundle...
Extracting FSLogix installation bundle...
Installing FSLogix...
Setting registry values...
Script executed successfully

  • 12
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值