-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.ps1
101 lines (100 loc) · 3.87 KB
/
install.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
Write-Host -Object "-- NEOTOKYO Dedicated Server Installer --"
[string] $Architecture = (Get-WmiObject -Class Win32_OperatingSystem -ComputerName $env:COMPUTERNAME).OSArchitecture
$steamcmd = @{}
$steamcmd['filename'] = 'steamcmd.exe'
$nssm = @{}
$nssm['filename'] = 'nssm.exe'
function menu {
Write-Host -Object "
1. Remote Installation
2. Local Installation
To exit just press enter.
"
$selection = Read-Host -Prompt "Select number & press enter"
switch ($selection) {
"1" { remote }
"2" { local }
}
}
function remote {
Write-Host -Object ""
if ($PSVersionTable.PSVersion.Major -lt 3) {
Write-Warning -Message "Your Client needs a PowerShell Version greater than 2.0 for Remote Installation!"
Read-Host -Prompt "
Press enter to exit"
break
}
$remotehost = Read-Host -Prompt "Please enter the full qualified domain name of your remote host"
$credential = Get-Credential -Message $remotehost
[string] $Architecture = Invoke-Command -ComputerName $remotehost -Credential $credential `
-ScriptBlock {
(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $env:COMPUTERNAME).OSArchitecture
}
if ($Architecture -notcontains "64-Bit") {
$nssm['filename'] = 'x86\nssm.exe'
}
if (-Not (Test-Path -Path $nssm.filename)) {
Write-Host -Object "
The File", $nssm.filename, "is missing!
Get the File from http://www.nssm.cc
and place it in the current directory."
break
}
if (-Not (Test-Path -Path $steamcmd.filename)) {
Write-Host -Object "
The File", $steamcmd.filename, "is missing!
Get the File from https://developer.valvesoftware.com/wiki/SteamCMD
and place it in the current directory."
break
}
Write-Host -Object "
Copying", $nssm.filename, "($Architecture) to", $env:TEMP, "on", $remotehost
$contents = [IO.File]::ReadAllBytes($nssm.filename)
$nssm['filename'] = 'nssm.exe'
Invoke-Command -ComputerName $remotehost -Credential $credential `
-ScriptBlock {
[IO.File]::WriteAllBytes((Join-Path -Path $env:TEMP -ChildPath $using:nssm.filename), $using:contents)
}
Write-Host -Object "
Copying", $steamcmd.filename, "to", $env:TEMP, "on", $remotehost
$contents = [IO.File]::ReadAllBytes($steamcmd.filename)
Invoke-Command -ComputerName $remotehost -Credential $credential `
-ScriptBlock {
[IO.File]::WriteAllBytes((Join-Path -Path $env:TEMP -ChildPath $using:steamcmd.filename), $using:contents)
}
Write-Host -Object "
Starting remote installation ...
"
Invoke-Command -ComputerName $remotehost -Credential $credential -FilePath (Join-Path -Path $PSScriptRoot -ChildPath "ntds.ps1")
}
function local {
Write-Host -Object ""
if ($Architecture -notcontains "64-Bit") {
$nssm['filename'] = 'x86\nssm.exe'
}
if (-Not (Test-Path -Path $nssm.filename)) {
Write-Host -Object "
The File", $nssm.filename, "is missing!
Get the File from http://www.nssm.cc
and place it in the current directory."
break
}
if (-Not (Test-Path -Path $steamcmd.filename)) {
Write-Host -Object "
The File", $steamcmd.filename, "is missing!
Get the File from https://developer.valvesoftware.com/wiki/SteamCMD
and place it in the current directory."
break
}
Write-Host -Object "
Copying", $nssm.filename, "($Architecture) to", $env:TEMP
Copy-Item -Path $nssm.filename -Destination $env:TEMP
Write-Host -Object "
Copying", $steamcmd.filename, "to", $env:TEMP
Copy-Item -Path $steamcmd.filename -Destination $env:TEMP
Write-Host -Object "
Starting local installation ...
"
Invoke-Expression -Command "powershell -NoProfile -ExecutionPolicy Bypass .\ntds.ps1"
}
menu