Sorry I am a bit late on this one, decided to add a new server crawler. This will automatically find all servers on your computer and make them available to manage.
You can download the script here (Full text copy at the bottom of this post):
http://www.denalicomputer.com/fileserver/SEMC.1.1.zip
Current features:
- Support for unlimited amount of servers!
- See log files for your servers easily!
- Quickly Start and Stop Servers
- Edit config files right from the interface
- Find all Service instances of your Servers
http://akmattb.blogspot.com/2014/06/space-engineers-managment-console.html
Future Features - http://akmattb.blogspot.com/2014/06/space-engineers-managment-console_22.html
$versionText = "akmattb's Space Engineers Management Console v1.1"
write-host $myinvocation.mycommand.path
write-host $versionText
write-host " Checking for admin credentials."
If (-NOT ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(`
[Security.Principal.WindowsBuiltInRole] "Administrator"))
{
try {
Write-Warning "Oops... you didnt run this as admin, trying to start powershell as admin. Next time start the Space Engineers Management Console as Admin (Right-Click)"
$arg = "-file `"$($MyInvocation.mycommand.path)`""
Start-Process "$psHome\powershell.exe" -Verb Runas -ArgumentList $arg -ErrorAction 'stop'
}
catch {
Write-Warning "Error - Failed to restart script with runas"
break
}
} else {
write-host "finding all server instances..."
#find all server instances
$dedicatedPerverPath = "C:\ProgramData\SpaceEngineersDedicated\"
$consolePerverPath = "~\AppData\Roaming\SpaceEngineersDedicated\"
$dedicatedServers = get-childitem $dedicatedPerverPath | Where-Object {$_.PSIsContainer} | foreach-object {$_.Name}
# $consoleServers = get-childitem $consolePerverPath | Where-Object {$_.PSIsContainer} | foreach-object {$_.Name}
do {
# SELECT Server
clear
write-host $versionText
write-host ""
write-host " Select a server to work with"
write-host "+---------------------------------------------------------------------------------+"
write-host ""
$menuNumberCount = 1
$menuOptions = @(0)
$dedicatedServers | foreach {
$dedicatedServerStatus = get-service -name $_
$runningText = " " + $menuNumberCount + " " + $_ + " "
write-host $runningText -noNewLine
if ($dedicatedServerStatus.Status -eq "Running") {
write-host "Running" -backgroundcolor DarkGreen -foregroundcolor White
} else {
write-host "Stopped" -backgroundcolor Red -foregroundcolor White
}
$menuOptions += ($_)
$menuNumberCount++
}
# $consoleServers | foreach { }
write-host ""
write-host " q Exit"
write-host ""
write-host "+---------------------------------------------------------------------------------+"
$mainMenuOption = read-host " which server do you want to manage"
if ($mainMenuOption -gt 0 -and $mainMenuOption -lt $menuNumberCount) {
$currentServer = $menuOptions[$mainMenuOption]
do { # User selected a server, lets show the other menu
# $userLeft = get-content C:\ProgramData\SpaceEngineersDedicated\Service\SpaceEngineers-Dedicated.log | select-string -pattern "User left "
# $userLeft.count
#get-content C:\ProgramData\SpaceEngineersDedicated\Service\SpaceEngineers-Dedicated.log | select-string -pattern "World request received:"
clear
write-host $versionText
write-host ""
# Show Log Files
write-host " Most Recent Log File Activity"
$theLog = $dedicatedPerverPath + "\" + $currentServer + "\SpaceEngineers-Dedicated.log"
write-host "+---------------------------------------------------------------------------------+"
get-childitem $theLog | foreach-object { write-host $_.FullName; Get-Content $_.Fullname | Select-Object -Last 15 }
write-host ""
write-host " Working With "$currentServer
write-host "+---------------------------------------------------------------------------------+"
write-host ""
$currentServerStatus = get-service -name $currentServer
$statusText = " 1 " + $currentServer + " "
write-host $statusText -noNewLine
if ($currentServerStatus.Status -eq "Running") {
write-host "Running" -backgroundcolor DarkGreen -foregroundcolor White
} else {
write-host "Stopped" -backgroundcolor Red -foregroundcolor White
}
write-host " 2 Edit "$currentServer" Config (will take effect on next server restart)"
write-host ""
write-host " enter To Refresh"
write-host ""
write-host " q Exit to main menu"
write-host ""
write-host "+---------------------------------------------------------------------------------+"
$choice = Read-Host " Choice"
switch ($choice) {
"1" {
if ($currentServerStatus.Status -eq "Running") {
stop-service $currentServerStatus
} else {
start-service $currentServerStatus
}
}
"2" {
$editConfig = $dedicatedPerverPath + "\" + $currentServer + "\SpaceEngineers-Dedicated.cfg"
Invoke-Item $editConfig
}
"q" {
$currentServer = 0
}
}
} until ($currentServer -eq 0)
}
} until ($mainMenuOption -eq "q")
clear
break
}
No comments:
Post a Comment