-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhstf-tools.ps1
87 lines (77 loc) · 2.22 KB
/
hstf-tools.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
# Must be running as administrator
$lab_pcs = 'lab209,lab210,lab211,lab212,lab213,lab214,lab215,lab207'.Split(',')
function testif-admin {
$user = [Security.Principal.WindowsIdentity]::GetCurrent();
(New-Object Security.Principal.WindowsPrincipal $user).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
}
function test-web-connection {
if (-not(testif-admin)) {
write-host "Must be running as administrator."
break
}
$lab_pcs | %{
$ErrorActionPreference = 'Stop'
$pc = $_
$src = 'http://www.msn.com'
$dst = 'c:\test-web-conn.log'
$wc = New-Object System.Net.WebClient
try {
Test-Connection $pc -count 1| Out-Null
$wc.DownloadFile($src,$dst)
remove-item $dst
Write-Host "$pc - succeeded"
}
catch {
Write-host "$pc - fail"
}
}
}
function shutdown-lab {
if (-not(testif-admin)) {
write-host "Must be running as administrator."
break
}
$lab_pcs | % {
$ErrorActionPreference = 'stop'
try {
$pc = $_
stop-computer -comp $pc -force
write-host "$pc - shutdown success"
}
catch {
write-host "$pc - shutdown failed"
}
}
}
function restart-lab {
$lab_pcs | % {
$ErrorActionPreference = 'stop'
try {
$pc = $_
restart-computer -comp $pc -force
write-host "$pc - shutdown success"
}
catch {
write-host "$pc - shutdown failed"
}
}
}
function install-choco {
Set-ExecutionPolicy Bypass -Scope Process -Force;
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
}
function install-common-apps {
choco install vcredist140 vcredist2015 sharex git adobereader vlc jre8 putty strawberryperl firefox googlechrome zoom dotnet4.5 python -y
}
function install-nvr-apps {
choco install tightvnc
}
function install-imageglass {
choco install imageglass -y
$extension = ".heic"
$imageGlassPath = "C:\Program Files\ImageGlass\ImageGlass.exe" # Update this path if your ImageGlass is installed elsewhere
$progId = "ImageGlass.heic"
# Register the file extension with a ProgID
New-Item -Path "HKCU:\Software\Classes\$extension" -Force | Out-Null
Set-ItemProperty -Path "HKCU:\Software\Classes\$extension" -Name "(Default)" -Value $progId
}