Changes for fixing bugs in code

This commit is contained in:
2021-12-15 09:38:58 +01:00
parent ae965aed86
commit d2a78fd86f
3 changed files with 34 additions and 9 deletions

View File

@@ -1,4 +1,5 @@
# Build 20. Using API 2
# Build 21. Using API 2
Write-Host "Starting Powerful Computer Manager..."
param([Int32]$startup=0)
#Write-Host $startup
$srcdir = $PSCommandPath | Split-Path -Parent
@@ -9,7 +10,8 @@ $64bit = [Environment]::Is64BitOperatingSystem
$computerName = [System.Net.Dns]::GetHostName()
$UUID=(Get-CimInstance Win32_ComputerSystemProduct).UUID
if ((Get-Host | Select-Object Version).Version.Major -lt 6){#Powershell Windows (Not Core)
# Powershell of Windows / Powershell Core
if ((Get-Host | Select-Object Version).Version.Major -lt 6){#Powershell Windows (Not Core) Powershell < 6
add-type -TypeDefinition @"
using System.Net;
using System.Security.Cryptography.X509Certificates;
@@ -27,6 +29,11 @@ if ((Get-Host | Select-Object Version).Version.Major -lt 6){#Powershell Windows
@{'Invoke-RestMethod:SkipCertificateCheck' = $true}
}
# Force install nuget if not installed (If not installed, it breaks uninstalls silently)
If(-not(Get-PackageProvider NuGet -ErrorAction silentlycontinue)){
Install-PackageProvider -Name NuGet -Confirm:$False -Force
}
$exists = Invoke-RestMethod -Method Post -Uri "$server/get/computerexists?ComputerName=$computerName&UUID=$UUID"
if ($exists.Result -eq "ERROR"){
@@ -117,13 +124,20 @@ foreach ($CookName in $cooks){
switch ($step[0].ToUpper()) { #Command
"UNINSTALL" { # Remove program
Get-Package -Name "$param*" -ErrorAction Continue #This will return error if program is not installed, do not see it.
if ($? -eq $True){ #If its True, is that package exists
Get-Package -Name "$param*" -ErrorVariable errvar | Uninstall-Package -ErrorVariable errvar
if ($? -eq $False){ # If fail then put 1 (When fail, powershell returns False)
$err = 1
}
}
# YOU HAVE TO CHECK IF NUGET IS INSTALLED, IF NOT, EXIT AS Error (If not doing this, program will stuck)
If(-not(Get-PackageProvider NuGet -ErrorAction silentlycontinue)){
Write-Host "You don't have NuGet installed! Aborting..."
$err = 1
}else{
# Uninstall package
Get-Package -Name "$param*" -ErrorAction Continue #This will return error if program is not installed, do not see it.
if ($? -eq $True){ #If its True, is that package exists
Get-Package -Name "$param*" -ErrorVariable errvar | Uninstall-Package -ErrorVariable errvar
if ($? -eq $False){ # If fail then put 1 (When fail, powershell returns False)
$err = 1
}
}
}
}
"SERV_DISABLE" { # Disable a service
Set-Service $param -StartupType Disabled -Status Stopped -ErrorVariable errvar

View File

@@ -1,5 +1,9 @@
# Changelog
## 2021/12/15
- Some fixes in code
- NuGet try to avoid stuck on a question
## 2020/09/11
- Fixes in webui in some options
- Fix IF64BIT/IF32BIT, was not working

View File

@@ -68,6 +68,13 @@ For server you can use Linux, Mac or Windows, and in theory any environment that
- For use of param "-startup 1" for cooks that has to be run without users, you will have to create a Task Scheduled GPO when workstation startsup/powers off with param -startup 1, like:
- Args: -executionpolicy bypass -windowstyle hidden -noninteractive -nologo -file "\\SERVER\SysVol\DOMAINNAME\scripts\client.ps1" -startup 1
- Note: You can add Windows GPO to show the poweron/poweroff/logon/logoff scripts, I think can be great (Mostly if command stucks):
- https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.Scripts::Run_Startup_Script_Visible
- https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.Scripts::Run_Shutdown_Script_Visible
- https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.Scripts::Run_Logoff_Script_Visible
- https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.Scripts::Run_Logon_Script_Visible
- (This in some enterprises is useful) https://admx.help/?Category=Windows_10_2016&Policy=Microsoft.Policies.WindowsLogon::VerboseStatus
## Control app
- Start control.pyw to setup password
- Go to a browser and load https://SERVER_IP:3434/ , login and manage all. control.pyw is the old way, it has to work, but its deprecated