Skip to content

Commit b40c5c4

Browse files
RodriguezRodriguez
Rodriguez
authored and
Rodriguez
committed
Add scripts to install RemoteApp and refresh icons.
1 parent bac6505 commit b40c5c4

File tree

2 files changed

+156
-0
lines changed

2 files changed

+156
-0
lines changed

RemoteApp/Install-Apps.ps1

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
$url = 'RDSBROKER.COMPANY.COM'
2+
$domain = 'DOMAIN'
3+
4+
Write-Host "Cleaning up previous RemoteApp install..."
5+
6+
try {
7+
$feeds = Get-ChildItem 'HKCU:\Software\Microsoft\Workspaces\Feeds' -ErrorAction Stop
8+
}
9+
catch {
10+
Write-Host "No feeds found"
11+
}
12+
13+
if ($feeds) {
14+
foreach ($feed in $feeds) {
15+
$id = (Get-ItemProperty $feed.PSPath -Name WorkspaceId).WorkspaceId
16+
17+
if ($id -eq $url) {
18+
Write-Host "Previous install found"
19+
20+
Write-Host "Removing Workspace folder..."
21+
$workspaceFolder = (Get-ItemProperty $feed.PSPath -Name WorkspaceFolder).WorkspaceFolder
22+
Remove-Item $workspaceFolder -Recurse -ErrorAction SilentlyContinue
23+
24+
Write-Host "Removing Desktop icons..."
25+
$startFolder = (Get-ItemProperty $feed.PSPath -Name StartMenuRoot).StartMenuRoot
26+
$apps = Get-ChildItem $startFolder
27+
$desktopIcons = Get-ChildItem "$env:USERPROFILE\Desktop"
28+
foreach ($icon in $desktopIcons) {
29+
if ($apps.Name -contains $icon.Name) {
30+
Remove-Item $icon.FullName
31+
}
32+
}
33+
34+
Write-Host "Removing Start Menu items..."
35+
Remove-Item $startFolder -Recurse
36+
37+
Write-Host "Removing registry items..."
38+
Remove-Item $feed.PSPath -Recurse
39+
}
40+
41+
Write-Host "Cleanup complete"
42+
43+
break
44+
}
45+
}
46+
47+
Write-Host "`n`nEnter your credentials..."
48+
49+
try {
50+
$creds = Get-Credential -Credential $null
51+
}
52+
catch {
53+
Write-Warning "You must enter credentials to complete the setup"
54+
Read-Host "`n`nPress [Enter] to exit"
55+
exit
56+
}
57+
58+
$username = $creds.UserName
59+
$password = $creds.GetNetworkCredential().Password
60+
61+
Write-Host "`n`nAdding credentials to Credential Manager..."
62+
cmdkey /add:$url /user:$domain$username /password:$password
63+
cmdkey /add:*.company.com /user:$domain$username /password:$password
64+
cmdkey /add:TERMSRV/$url /user:$domain$username /password:$password
65+
66+
Write-Host "`n`nSetting up Workspace..."
67+
68+
$winVer = [System.Environment]::OSVersion.Version.Major
69+
if ($winVer -ne "10" ) {
70+
Write-Host "Windows 10 not detected"
71+
$userProf = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\RemoteApp and Desktop Connections\Work Resources\"
72+
}
73+
else {
74+
Write-Host "Windows 10 detected"
75+
$userProf = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Work Resources (RADC)"
76+
}
77+
78+
# Create the wcx file
79+
Write-Host "Creating setup wcx file..."
80+
$wcxPath = "$env:TEMP\RDSWebSetup.wcx"
81+
$config = @"
82+
<?xml version=`"1.0`" encoding=`"utf-8`" standalone=`"yes`"?>
83+
<workspace name=`"Workspace Resources`" xmlns=`"http://schemas.microsoft.com/ts/2008/09/tswcx`" xmlns:xs=`"http://www.w3.org/2001/XMLSchema`">
84+
<defaultFeed url=`"https://$url/RDWeb/Feed/webfeed.aspx`" />
85+
</workspace>
86+
"@
87+
New-Item -Path $wcxPath -ItemType "File" -Value $config -Force | Out-Null
88+
89+
# Silently run the RemoteApp config
90+
Write-Host "Running wcx setup..."
91+
rundll32.exe tsworkspace, WorkspaceSilentSetup $wcxPath
92+
93+
94+
95+
# Wait until the icons appear in the user profile and then copy them to the desktop
96+
Write-Host "Waiting for Workspace icons to be created..."
97+
$counter = 0
98+
$timeout = $false
99+
100+
while (-not (Test-Path $userProf) -and $counter -lt 15) {
101+
Start-Sleep -Seconds 2
102+
$counter++
103+
}
104+
105+
if ($counter -eq 15) {
106+
$timeout = $true
107+
}
108+
109+
$found = $false
110+
111+
$feeds = Get-ChildItem 'HKCU:\Software\Microsoft\Workspaces\Feeds'
112+
foreach ($feed in $feeds) {
113+
$id = (Get-ItemProperty $feed.PSPath -Name WorkspaceId).WorkspaceId
114+
115+
if ($id -eq $url) {
116+
$found = $true
117+
}
118+
}
119+
120+
if (-not $found -or $timeout) {
121+
Write-Host "`n`nCredentials invalid or timeout reached. Please follow the instructions in the new window..." -ForegroundColor Red
122+
123+
Start-Process $wcxPath -Wait
124+
}
125+
126+
Remove-Item $wcxPath
127+
128+
Write-Host "`n`nCopying icons to desktop..."
129+
Copy-Item "$userProf\*" "$env:USERPROFILE\Desktop\" -Recurse -Force
130+
131+
Read-Host "`n`nPress [Enter] to exit"
132+
exit

RemoteApp/Update-Apps.ps1

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
$url = 'RDSBROKER.COMPANY.COM'
2+
3+
$feeds = Get-ChildItem 'HKCU:\Software\Microsoft\Workspaces\Feeds'
4+
foreach ($feed in $feeds) {
5+
$id = (Get-ItemProperty $feed.PSPath -Name WorkspaceId).WorkspaceId
6+
7+
if ($id -eq $url) {
8+
# Remove Start folder and desktop icons
9+
$startFolder = (Get-ItemProperty $feed.PSPath -Name StartMenuRoot).StartMenuRoot
10+
$apps = Get-ChildItem $startFolder
11+
$desktopIcons = Get-ChildItem "$env:USERPROFILE\Desktop"
12+
foreach ($icon in $desktopIcons) {
13+
if ($apps.Name -contains $icon.Name) {
14+
Remove-Item $icon.FullName
15+
}
16+
}
17+
}
18+
}
19+
20+
rundll32 tsworkspace,TaskUpdateWorkspaces2
21+
22+
Start-Sleep -Seconds 2
23+
24+
Copy-Item "$startFolder\*" "$env:USERPROFILE\Desktop\" -Recurse -Force

0 commit comments

Comments
 (0)