Skip to content

Commit 1d498ca

Browse files
Remote Desktop Migration Tool - Updated Script and Instructions (#47)
* Update Get-AVDW365Gateways.ps1 Changed URL to GCCH JSON Download * Squashed commit of the following: commit 33f3d0b Author: Donna Ryan <100233767+DonnaRyanMicrosoft@users.noreply.github.com> Date: Wed Mar 26 15:17:12 2025 -0400 Initial Commit Includes both detection and remediation script, plus readme.md files * Initial Commit * Changed MSRDC uninstall order Also some minor formatting changes * DisableAutoUpdate reg key support created function to allow admins to set the DisableAutoUpdate registry key * Updated outputs minor bug fix * Added logging for install processes Store and Winget installation output now logged separately * Fixed ID10T error deleted extra stuff that shouldn't have been pasted * added comments * Added Param Block commented out old variable assignments * Formatting * Logging enabled + error handling Added logging module, Added error handling Added rename MSIX download and rename to original file name. * Added Readme.Md instructions Wrote the basic instructions * Changed MSRDC Uninstall Parameter Changed parameter type to Switch. This makes the parameter true if present, otherwise false. Changed the name of the parameter for clarity. * Updated Readme.md Removed notes from head of script. Updated Readme.md * Formatting and Copyright Minor formatting changes with copyright, name, and version added * Changed name of file to new name renamed script * Changed Folder Name Renamed Folder * Updated Documentation Also changed log name to reflect new script name * Added WAIT to msiexec command, fixed RD query Added -WAIT to the msiexec uninstall command string. Also changed RD client query from "-like" to "-eq" * New Version - 1.1 Changed script to be run in System Context (deploy from Intune). Updated Readme to reflect changes. * update readme Added Troubleshooting section * GUID Added GUID to temp folder * Updated Readme.md Now includes Intune deployment instructions and troubleshooting * update to package uninstall method changed error message flag to information as the detection of the package returns an error if the package is not installed. * Updated deployment instructions Updated deployment instructions --------- Signed-off-by: Donna Ryan <100233767+DonnaRyanMicrosoft@users.noreply.github.com>
1 parent 8834a74 commit 1d498ca

2 files changed

Lines changed: 205 additions & 228 deletions

File tree

Remote Desktop Client Migration Script/Remote Desktop Client Migration Script.ps1

Lines changed: 38 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,10 @@ See LICENSE in the project root for license information.
55
#>
66

77
#Microsoft Remote Desktop Client Migration Script
8-
#Version 1.0
8+
#Version 1.2
99
#For more info, visit: https://github.com/microsoft/Windows365-PSScripts
1010

1111
Param(
12-
[parameter(mandatory = $false, HelpMessage = "Where to source installer payload")]
13-
[ValidateSet('Store','WinGet','MSIX')]
14-
[string]$source = "Store",
1512
[parameter(mandatory = $false, HelpMessage = "Value to set auto update reg key")]
1613
[ValidateSet(0,1,2,3)]
1714
[int]$DisableAutoUpdate = 0,
@@ -87,12 +84,11 @@ function uninstall-MSRDC{
8784
}
8885
catch
8986
{
90-
Update-Log -data $_.Exception.Message -Class Error -Output Both
87+
Update-Log -data $_.Exception.Message -Class Information -Output Both
9188
}
9289

9390
if ($MSRDC.name -eq "Remote Desktop"){
9491
update-log -Data "Remote Desktop Install Found" -Class Information -Output Both
95-
#update-log -Data "Version: " $MSRDC.Version
9692
update-log -Data "Uninstalling Remote Desktop" -Class Information -Output Both
9793
try{
9894
Uninstall-Package -Name "Remote Desktop" -force -ErrorAction Stop| Out-Null
@@ -111,51 +107,41 @@ function uninstall-MSRDC{
111107
}
112108
}
113109

114-
#function to install Windows App from MS Store - write install process log to $env:windir\temp\WindowsAppStoreInstall.log
115-
function install-windowsappstore{
116-
update-log -Data "Writing install process log to $env:windir\temp\WindowsAppStoreInstall.log" -Class Information -Output Both
117-
try{
118-
invoke-command -ScriptBlock { winget install 9N1F85V9T8BN --accept-package-agreements --accept-source-agreements} | Out-File -FilePath $env:windir\temp\WindowsAppStoreInstall.log -Append #MS Store Install
119-
}
120-
catch
121-
{
122-
Update-Log -data $_.Exception.Message -Class Error -Output Both
123-
Exit 1
124-
}
125-
}
126-
127-
#Function to install Windows App from Winget CDN - write install process log to $env:windir\temp\WindowsAppWinGetInstall.log
128-
function install-windowsappwinget{
129-
update-log -Data "Writing install process log to $env:windir\temp\WindowsAppWinGetInstall.log" -Class Information -Output Both
130-
try{
131-
invoke-command -ScriptBlock {winget install Microsoft.WindowsApp --accept-package-agreements --accept-source-agreements} | Out-File -FilePath $env:windir\temp\WindowsAppWinGetInstall.log -Append #Winget Install
132-
}
133-
catch
134-
{
135-
Update-Log -data $_.Exception.Message -Class Error -Output Both
136-
Exit 1
137-
}
138-
}
139-
140110
#Function to install Windows App from MSIX direct download
141111
function install-windowsappMSIX{
142-
112+
$guid = New-Guid
143113
try{
144-
if ((test-path -Path $env:windir\Temp\WindowsApp.msix) -eq $true){Remove-Item -Path $env:windir\Temp\WindowsApp.msix -Force -ErrorAction Stop}
114+
update-log -data "Downloading payload" -Class Information -Output Both
115+
#if ((test-path -Path $env:windir\Temp\WindowsApp.msix) -eq $true){Remove-Item -Path $env:windir\Temp\WindowsApp.msix -Force -ErrorAction Stop}
145116

146-
$Payload = Invoke-WebRequest -uri "https://go.microsoft.com/fwlink/?linkid=2262633" -UseBasicParsing -OutFile $env:windir\Temp\WindowsApp.msix -PassThru -ErrorAction Stop
117+
new-item -Path $env:windir\temp -Name $guid.guid -ItemType Directory -Force -ErrorAction Stop | Out-Null
118+
$path = $env:windir + "\temp\" + $guid.guid
119+
120+
$Payload = Invoke-WebRequest -uri "https://go.microsoft.com/fwlink/?linkid=2262633" -UseBasicParsing -OutFile $path\WindowsApp.msix -PassThru -ErrorAction Stop
147121
$filename = ($Payload.BaseResponse.ResponseUri.AbsolutePath -replace ".*/")
148122

149-
if ((test-path -Path $env:windir\Temp\$filename) -eq $true){Remove-Item -Path $env:windir\Temp\$filename -Force -ErrorAction Stop}
123+
#if ((test-path -Path $env:windir\Temp\$filename) -eq $true){Remove-Item -Path $env:windir\Temp\$filename -Force -ErrorAction Stop}
150124

151-
Rename-Item -Path $env:windir\Temp\WindowsApp.msix -NewName $filename -Force -ErrorAction Stop
152-
update-log -Data "Downloaded $filename to $env:windir\temp" -Class Information -Output Both
125+
Rename-Item -Path $path\WindowsApp.msix -NewName $filename -Force -ErrorAction Stop
126+
update-log -Data "Downloaded $filename to $path" -Class Information -Output Both
127+
153128
}
154129
catch{
155130
Update-Log -data $_.Exception.Message -Class Error -Output Both
156131
}
157132
try{
158-
Add-AppxPackage -Path $env:windir\temp\$filename -ErrorAction Stop
133+
#Add-AppxPackage -Path $env:windir\temp\$filename -ErrorAction Stop
134+
update-log -data "Installing Windows App MSIX package..." -Class Information -Output Both
135+
add-appxprovisionedpackage -PackagePath $path\$filename -online -SkipLicense -ErrorAction Stop | Out-Null
136+
}
137+
catch{
138+
Update-Log -data $_.Exception.Message -Class Error -Output Both
139+
}
140+
141+
try{
142+
update-log -data "Cleaning up temp folder and files..." -Class Information -Output Both
143+
remove-item -Path $path -Recurse -Force -ErrorAction Stop | Out-Null
144+
159145
}
160146
catch{
161147
Update-Log -data $_.Exception.Message -Class Error -Output Both
@@ -164,13 +150,18 @@ function install-windowsappMSIX{
164150

165151
#Function to check if Windows App is installed
166152
function invoke-WAInstallCheck{
167-
if ((($testWA = get-appxpackage -name MicrosoftCorporationII.Windows365).name) -eq "MicrosoftCorporationII.Windows365" ){
168-
update-log -Data "Windows App Installation found." -Class Information -Output Both
153+
154+
$WAappx = (Get-AppxProvisionedPackage -online | Where-Object {$_.DisplayName -eq "MicrosoftCorporationII.Windows365"})
155+
156+
if ($WAappx.DisplayName -eq "MicrosoftCorporationII.Windows365"){
157+
update-log -Data "Windows App Provisioning Package installation found." -Class Information -Output Both
158+
update-log -data $WAappx.displayname -Class Information -Output Both
159+
update-log -data $WAappx.version -Class Information -Output Both
169160
Return 0
170161
}
171162
else
172163
{
173-
update-log -Data "Windows App installation not found." -Class Information -Output Both
164+
update-log -Data "Windows App Provisioning Package installation not found." -Class Information -Output Both
174165
Return 1
175166
}
176167
}
@@ -190,24 +181,19 @@ function invoke-disableautoupdate($num){
190181
}
191182
}
192183

184+
185+
193186
#check if Windows App is installed. If so, skip installation. Else, install
194187
if ((invoke-WAInstallCheck) -eq 0){
195188
update-log -Data "Skipping Windows App Installation" -Class Information -Output Both
196189
}
197190
else
198191
{
199-
if ($source -eq "Store"){
200-
update-log -Data "Starting Windows App installation from Microsoft Store" -Class Information -Output Both
201-
install-windowsappstore
202-
}
203-
if ($source -eq "WinGet"){
204-
update-log -Data "Starting Windows App installation from WinGet" -Class Information -Output Both
205-
install-windowsappwinget
206-
}
207-
if ($source -eq "MSIX"){
192+
193+
#if ($source -eq "MSIX"){
208194
update-log -Data "Starting Windows App installation from MSIX download" -Class Information -Output Both
209195
install-windowsappMSIX
210-
}
196+
# }
211197
}
212198

213199
#verify if Windows App has now been installed. If so, move to uninstalling MSRDC. Else, fail.

0 commit comments

Comments
 (0)