GUI version to control all

This commit is contained in:
2019-06-11 11:14:38 +02:00
parent c4f1510e25
commit 1873e21c71
11 changed files with 366 additions and 400 deletions

View File

@@ -1,12 +1,14 @@
# Build 2
# Build 5
$root = $PSCommandPath | Split-Path -Parent
. $root\config.ps1
$server = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).server
$resources = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).resources
$computerName = $env:COMPUTERNAME
$computerName = [System.Net.Dns]::GetHostName()
$UUID=(get-wmiobject Win32_ComputerSystemProduct).UUID
$exists = Invoke-RestMethod -Method Get -Uri "$server/get/computerexists?ComputerName=$computerName&UUID=$UUID"
if ($exists.Result -eq 0){
if ($exists.Result -eq "ERROR"){
Write-Host "Computer outside database:" $computerName
exit
}
@@ -30,7 +32,7 @@ $lastUser = (Get-CimInstance -ClassName Win32_ComputerSystem -Property UserName
Invoke-RestMethod -Method Get -Uri "$server/upd/computer?ComputerName=$computerName&UUID=$UUID&LastUser=$lastUser" | out-null
$cooks = Invoke-RestMethod -Method Get -Uri "$server/get/cook?ComputerName=$computerName&UUID=$UUID"
$cooks = Invoke-RestMethod -Method Get -Uri "$server/get/cookpend?ComputerName=$computerName&UUID=$UUID"
foreach ($CookName in $cooks){
Set-Location $env:temp # For downloading/copying items, use system temp location
@@ -79,7 +81,7 @@ foreach ($CookName in $cooks){
$err = 1
}
}
"KILL_PROCESS" {
{$_ -in "KILL_PROCESS","KILLPROCESS"} {
$p = Get-Process -Name "$param"
if ($? -eq $true){ # Only do something if exists
Stop-Process -InputObject $p -Force -ErrorVariable errvar -ErrorAction Continue
@@ -90,7 +92,7 @@ foreach ($CookName in $cooks){
}
"CMD" { # Run a cmd command. Note: Runs at high priv.
cmd.exe /c "$param"
if ($? -eq $false){ # Error in CMD
if ($LASTEXITCODE -ne 0){ # Error in CMD
$err = 1
}
}
@@ -208,7 +210,7 @@ foreach ($CookName in $cooks){
if ($cook.runever -eq "1"){
$err = -1 # This is for run but not for error, is by cook saw.
}
Invoke-RestMethod -Method Get -Uri "$server/set/cookstatus?ComputerName=$computerName&UUID=$UUID&CookName=$CookName&Revision=$CookRevision&Error=$err&ErrorDesc=$errvar" | out-null
Invoke-RestMethod -Method Get -Uri "$server/upd/cookstatus?ComputerName=$computerName&UUID=$UUID&CookName=$CookName&Revision=$CookRevision&Error=$err&ErrorDesc=$errvar" | out-null
#Delete files copied to temp for saving space
foreach ($element in $filesCopied) {