mirror of
https://gitlab.com/JKANetwork/powerfulcomputermanager.git
synced 2026-03-03 00:56:45 +01:00
Changes for fixing bugs in code
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user