forked from ChayScripts/Citrix-VDA-Upgrade-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVDA Upgrade.ps1
37 lines (28 loc) · 1.63 KB
/
VDA Upgrade.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
$vdilist = Get-Content C:\temp\list.txt
foreach ($vdi in $vdilist) {
Write-Host "Working on $vdi"
if (!(Test-Path -Path \\$vdi\c$\temp)) {
New-Item -ItemType Directory -Path \\$vdi\c$ -Name Temp
Copy-Item "\\server\install.bat" -Destination \\$vdi\c$\temp -Force
Copy-Item "\\server\remove.bat" -Destination \\$vdi\c$\temp -Force
Copy-Item "\\server\VDAWorkstationSetup_1912.exe" -Destination \\$vdi\c$\temp -Force
}
else {
Copy-Item "\\server\install.bat" -Destination \\$vdi\c$\temp -Force
Copy-Item "\\server\remove.bat" -Destination \\$vdi\c$\temp -Force
Copy-Item "\\server\VDAWorkstationSetup_1912.exe" -Destination \\$vdi\c$\temp -Force
}
Invoke-Command -ComputerName $vdi -Scriptblock {
$time = (Get-Date).AddMinutes(3)
$action = New-ScheduledTaskAction -Execute 'c:\temp\remove.bat'
$trigger = New-ScheduledTaskTrigger -Once -At $time
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAUninstall" -Description "Citrix VDA Uninstall"
}
Invoke-Command -ComputerName $vdi -Scriptblock {
$action = New-ScheduledTaskAction -Execute 'c:\temp\install.bat'
$trigger = New-ScheduledTaskTrigger -AtStartup
$principal = New-ScheduledTaskPrincipal -RunLevel Highest -UserID "NT AUTHORITY\SYSTEM" -LogonType S4U
Register-ScheduledTask -Action $action -Trigger $trigger -Principal $principal -TaskName "VDAInstall" -Description "Citrix VDA Install"
}
}