-
Notifications
You must be signed in to change notification settings - Fork 3
/
AdminChecks.ps1
143 lines (134 loc) · 4.99 KB
/
AdminChecks.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
function Check-Permission()
{
$err = $false
$paths = @("coolOrange", "Autodesk")
foreach ($path in $paths)
{
try
{
$Folder = $env:ProgramData + "\" + $path
Write-Host "`nChecking for $Folder"
$File = $Folder + "\writeTest.txt"
Out-File -FilePath $File
Write-Host "Created Text file"
Set-Content -Path $File -Value 'Hello, World'
Write-Host "Set content"
$items = Get-ChildItem -Path $Folder
Write-Host "Retrieved folder content"
Remove-Item -Path $File
Write-Host "Deleted File"
Write-Host -ForegroundColor Green "Successfully verified Read-Write permission for $Folder"
}
catch
{
Write-Host -ForegroundColor Red "Failed to verify Read-Write permission for $Folder"
$err = $true
}
}
if (-not $err)
{
Download-Setups
}
}
function Download-Setups()
{
$products = @{
"powerJobs" = @{
"2021" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerJobsProcessor23.0_Vault2021.exe";
"2022" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerJobsProcessor23.0_Vault2022.exe";
"2023" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerJobsProcessor23.0_Vault2023.exe"
};
"powerGate" = @{
"2021" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGate23.0_Vault2021.exe";
"2022" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGate23.0_Vault2022.exe";
"2023" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGate23.0_Vault2023.exe"
};
"powerGateServer" = @{
"2021" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGateServer21.0_x64.msi";
"2022" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGateServer21.0_x64.msi";
"2023" = "https://coolorangedownloads.blob.core.windows.net/downloads/cO_powerGateServer21.0_x64.msi";
}
}
Write-Host "`nEnter Vault Version Year:"
$vaultVersion = ""
while ($true)
{
if (-not $products[$vaultVersion])
{
[string]$vaultVersion = Read-Host
}
break
}
$installed = @()
foreach($p in $products.Keys)
{
while ($true) {
Write-Host "`nInstall $p`? ('y', 'n')" -ForegroundColor Blue
$ins = Read-Host
if ($ins -eq 'y')
{
$url = $products[$p][$vaultVersion]
$prod = $url.Split("/")
$prod = $prod[$prod.Length-1]
$output = $env:USERPROFILE + "\Downloads\$prod"
$start_time = Get-Date
Write-Host "`nDownloading $p..."
$progressPreference = 'silentlyContinue'
Invoke-WebRequest -Uri $url -OutFile $output
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s) for $p"
$installed += $p
break
}
elseif ($ins -eq 'n')
{
break
}
else
{
Write-Host -ForegroundColor Red "Invalid input"
}
}
}
Write-Host "`nInstall setups? ('y', 'n')" -ForegroundColor Blue
$install = Read-Host
while ($true)
{
if ($install.ToLower() -eq "y")
{
foreach($p in $installed)
{
$url = $products[$p][$vaultVersion]
$prod = $url.Split("/")
$prod = $prod[$prod.Length-1]
$file = $env:USERPROFILE + "\Downloads\$prod"
Write-Host "`Starting installation for $p..."
if ($file.Contains(".exe"))
{
$process = Invoke-Command -ScriptBlock { Start-Process $file -ArgumentList "/q ACCEPT_EULA=1" -Wait -PassThru -Verb RunAs}
}
elseif ($file.Contains(".msi"))
{
$process = Invoke-Command -ScriptBlock { Start-Process msiexec.exe -Wait -ArgumentList "/I $file /quiet" -PassThru -Verb RunAs}
}
switch ($process.ExitCode)
{
0 { Write-Host "Finished installation for $prod" }
1603 { Write-Host -ForegroundColor Yellow "A version of $p might already be installed or Vault Version differs from $vaultVersion." }
default { Write-Host -ForegroundColor Red "Failed to install $prod" }
}
}
break
}
elseif ($install.ToLower() -eq "n")
{
Write-Host "Cancelled installation"
break
}
else
{
Write-Host -ForegroundColor Red "Invalid input"
}
}
}
Check-Permission