-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathrmm_deploy.ps1
68 lines (61 loc) · 2.51 KB
/
rmm_deploy.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#This can either be a path to a local file, or a URL
$Pathtologo = 'valuegoeshere'
#Setting some default paths
$Logfile = "C:\ProgramData\TED\Install.log"
$downloadURL = 'https://github.com/HealthITAU/TED/releases/latest/download/TED-x64.exe'
$TEDPath = 'C:\ProgramData\TED\Ted.exe'
$ShortcutLocation = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup\TED.lnk"
#Function for logging
function WriteLog
{
Param ([string]$LogString)
$Stamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss")
$LogMessage = "$Stamp $LogString"
Add-content $LogFile -value $LogMessage
}
#function to create or modify a shortcut
function Set-Shortcut
{
param ( [string]$SourceExe,[string]$Arguments, [string]$DestinationPath )
$WshShell = New-Object -comObject WScript.Shell
$Shortcut = $WshShell.CreateShortcut($DestinationPath)
$Shortcut.TargetPath = $SourceExe
$Shortcut.Arguments = $Arguments
$Shortcut.Save()
}
#Create dir and download file if dir not exists
if(!(test-path -Path C:\ProgramData\TED)){
md C:\ProgramData\TED
#find Windows Architecture relevant download link
$platform = try{Get-CimInstance -classname Win32_Processor| Select-Object -ExpandProperty Architecture}
catch [System.Management.Automation.RuntimeException]{get-wmiobject Win32_Processor | Select-Object -ExpandProperty Architecture}
Switch($platform) {
0 {
$downloadURL = 'https://github.com/HealthITAU/TED/releases/latest/download/TED-x86.exe'
WriteLog '32 bit Processor detected, downloading TED for x86 Architecture'
}
9 {
$downloadURL = 'https://github.com/HealthITAU/TED/releases/latest/download/TED-x64.exe'
WriteLog '64 bit Processor detected, downloading TED for x64 Architecture'
}
12 {
$downloadURL = 'https://github.com/HealthITAU/TED/releases/latest/download/TED-winarm64.exe'
WriteLog 'ARM Processor detected, downloading TED for ARM Architecture'
}
default{ $NoPlatform = $true }
}
if(!$NoPlatform) {
wget -OutFile $TEDPath $downloadURL
}
else {
Write-Output "Cannot determine Windows Arcitecture, defaulting to 64bit"
WriteLog "Cannot determine Windows Arcitecture, defaulting to 64bit"
wget -OutFile $TEDPath $downloadURL
}
}
WriteLog "Creating Shortcut with switches to image provided"
if($Pathtologo -eq 'valuegoeshere'){ $Switches = "" }
else{
$Switches = "-i $($Pathtologo)"
}
Set-ShortCut $TEDPath $Switches $ShortcutLocation