Translate

Azure Virtual Desktop Page

Azure Virtual Desktop Resources (incl. labs)

(updated 04/06/2023 - New labs)


Powershell Script to install FSLogix in a lab environment!

(Take care of the StorageAccount name. You need to change it in line 2!)

#Variables

$storageAccountName = "NameofStorageAccount" 


#Create Directories

$LabFilesDirectory = "C:\LabFiles"


if(!(Test-path -Path "$LabFilesDirectory")){

New-Item -Path $LabFilesDirectory -ItemType Directory |Out-Null

}

if(!(Test-path -Path "$LabFilesDirectory\FSLogix")){

New-Item -Path "$LabFilesDirectory\FSLogix" -ItemType Directory |Out-Null

}


 #Download FSLogix Installation bundle


 if(!(Test-path -Path "$LabFilesDirectory\FSLogix_Apps_Installation.zip")){

       Invoke-WebRequest -Uri "https://experienceazure.blob.core.windows.net/templates/wvd/FSLogix_Apps_Installation.zip" -OutFile     "$LabFilesDirectory\FSLogix_Apps_Installation.zip"


 #Extract the downloaded FSLogix bundle

 function Expand-ZIPFile($file, $destination){

     $shell = new-object -com shell.application

     $zip = $shell.NameSpace($file)

     foreach($item in $zip.items()){

     $shell.Namespace($destination).copyhere($item)

     }

 }


 Expand-ZIPFile -File "$LabFilesDirectory\FSLogix_Apps_Installation.zip" -Destination "$LabFilesDirectory\FSLogix"


}

   #Install FSLogix

   if(!(Get-WmiObject -Class Win32_Product | where vendor -eq "FSLogix, Inc." | select Name, Version)){

       $pathvargs = {C:\LabFiles\FSLogix\x64\Release\FSLogixAppsSetup.exe /quiet /install }

       Invoke-Command -ScriptBlock $pathvargs

   }

   #Create registry key 'Profiles' under 'HKLM:\SOFTWARE\FSLogix'

   $registryPath = "HKLM:\SOFTWARE\FSLogix\Profiles"

   if(!(Test-path $registryPath)){

       New-Item -Path $registryPath -Force | Out-Null

   }


   #Add registry values to enable FSLogix profiles, add VHD Locations, Delete local profile and FlipFlop Directory name

   New-ItemProperty -Path $registryPath -Name "VHDLocations" -Value "\\$storageAccountName.file.core.windows.net\userprofile" -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


   #Display script completion in the console

   Write-Host "Script Executed successfully"


Example Script for LogAnalytics Queries

WVDConnections 

|sort by TimeGenerated asc, CorrelationId

 |summarize Connectcount = dcount(CorrelationId) by bin(TimeGenerated, 1d),UserName = toupper(trim_end("@.*",UserName))


Microsoft VDI Teams own Powershell Script to Optimize VDI Images

https://github.com/The-Virtual-Desktop-Team/Virtual-Desktop-Optimization-Tool

Automatic Scaling (how to and script)


AVD Client Cleanup (Script)


Image Customization Script (with GUI)

Script it self WVD/Image-Build/Customizations at master · shawntmeyer/WVD (github.com)

Automatic Download via this link: DownGit (minhaskamal.github.io)