From d2a78fd86f6b17fb8d201c6bfc9caaf8e6743eef Mon Sep 17 00:00:00 2001 From: Kevin Puertas Ruiz Date: Wed, 15 Dec 2021 09:38:58 +0100 Subject: [PATCH] Changes for fixing bugs in code --- client/client.ps1 | 32 +++++++++++++++++++++++--------- docs/changelog.md | 4 ++++ docs/index.md | 7 +++++++ 3 files changed, 34 insertions(+), 9 deletions(-) diff --git a/client/client.ps1 b/client/client.ps1 index 6298d28..f21f3e4 100644 --- a/client/client.ps1 +++ b/client/client.ps1 @@ -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 diff --git a/docs/changelog.md b/docs/changelog.md index 439e99e..8795f03 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 diff --git a/docs/index.md b/docs/index.md index 8f95408..5ffeda7 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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