mirror of
https://gitlab.com/JKANetwork/powerfulcomputermanager.git
synced 2026-02-25 14:33:44 +01:00
Changes to doc and api/app for be able to record more things
This commit is contained in:
@@ -1,76 +0,0 @@
|
||||
$root = $PSCommandPath | Split-Path -Parent
|
||||
. $root\config.ps1
|
||||
|
||||
$table = (Invoke-RestMethod -Method Get -Uri "$server/get/computers") # Get all computers
|
||||
$DNSPrefix = (get-DnsClientGlobalSetting).SuffixSearchList[0] # Get DNS Prefix, needed to search computers in some environments
|
||||
|
||||
|
||||
$array = @()
|
||||
|
||||
function getPrograms($computername) {
|
||||
|
||||
|
||||
#Define the variable to hold the location of Currently Installed Programs
|
||||
|
||||
$UninstallKey="SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall"
|
||||
|
||||
#Create an instance of the Registry Object and open the HKLM base key
|
||||
|
||||
$reg=[microsoft.win32.registrykey]::OpenRemoteBaseKey('LocalMachine',$computername)
|
||||
|
||||
#Drill down into the Uninstall key using the OpenSubKey Method
|
||||
|
||||
$regkey=$reg.OpenSubKey($UninstallKey)
|
||||
|
||||
#Retrieve an array of string that contain all the subkey names
|
||||
|
||||
$subkeys=$regkey.GetSubKeyNames()
|
||||
|
||||
#Open each Subkey and use GetValue Method to return the required values for each
|
||||
|
||||
$allprogs = @()
|
||||
|
||||
foreach($key in $subkeys){
|
||||
|
||||
$thisKey=$UninstallKey+"\\"+$key
|
||||
|
||||
$thisSubKey=$reg.OpenSubKey($thisKey)
|
||||
|
||||
$obj = New-Object PSObject
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name "ComputerName" -Value $computername
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name "DisplayName" -Value $($thisSubKey.GetValue("DisplayName"))
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name "DisplayVersion" -Value $($thisSubKey.GetValue("DisplayVersion"))
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name "InstallLocation" -Value $($thisSubKey.GetValue("InstallLocation"))
|
||||
|
||||
$obj | Add-Member -MemberType NoteProperty -Name "Publisher" -Value $($thisSubKey.GetValue("Publisher"))
|
||||
|
||||
|
||||
$allprogs += $obj
|
||||
|
||||
}
|
||||
|
||||
return $allprogs
|
||||
}
|
||||
|
||||
|
||||
foreach ($comp in $table){
|
||||
$name = -join($comp.Name,".",$DNSPrefix);
|
||||
if (Test-Connection -ComputerName $name -Quiet){
|
||||
Write-Output $name
|
||||
$array += getPrograms($name)
|
||||
}else{
|
||||
Write-Output "$name Offline"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#$array | Where-Object { $_.DisplayName } | select ComputerName, DisplayName, DisplayVersion, Publisher | ft -auto
|
||||
|
||||
$array | Where-Object { $_.DisplayName } | select ComputerName, DisplayName, DisplayVersion | export-csv "$PSScriptRoot\..\Reports\software.csv" -NoTypeInformation -Delimiter ";" -Encoding ASCII
|
||||
Write-Host "Guardado en ..\Reports\software.csv"
|
||||
#$content = [System.IO.File]::ReadAllText("$PSScriptRoot\Reports\software.csv").Replace("A","")
|
||||
#[System.IO.File]::WriteAllText("$PSScriptRoot\Reports\software.csv", $content)
|
||||
@@ -1,13 +1,13 @@
|
||||
# Build 9
|
||||
# Build 11
|
||||
param([Int32]$startup=0)
|
||||
Write-Host $startup
|
||||
$root = $PSCommandPath | Split-Path -Parent
|
||||
$server = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).server
|
||||
$resources = (Get-Content "$root\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).resources
|
||||
#Write-Host $startup
|
||||
$srcdir = $PSCommandPath | Split-Path -Parent
|
||||
$server = (Get-Content "$srcdir\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).server
|
||||
$resources = (Get-Content "$srcdir\configpcm.ini" | select -Skip 1 | ConvertFrom-StringData).resources
|
||||
$64bit = [Environment]::Is64BitOperatingSystem
|
||||
|
||||
$computerName = [System.Net.Dns]::GetHostName()
|
||||
$UUID=(get-wmiobject Win32_ComputerSystemProduct).UUID
|
||||
$UUID=(Get-CimInstance Win32_ComputerSystemProduct).UUID
|
||||
|
||||
$exists = Invoke-RestMethod -Method Get -Uri "$server/get/computerexists?ComputerName=$computerName&UUID=$UUID"
|
||||
if ($exists.Result -eq "ERROR"){
|
||||
@@ -29,15 +29,35 @@ if ($SOVersion -match "^10.0."){ #If its Windows 10, add revision number for kno
|
||||
}
|
||||
|
||||
# Update Computer Data
|
||||
$CPUInfo = Get-WmiObject Win32_Processor
|
||||
$RAMInstalled = Get-WmiObject CIM_PhysicalMemory | Measure-Object -Property capacity -Sum | ForEach-Object {[math]::round(($_.sum / 1MB),2)}
|
||||
$paramInvoke = -join("$server/upd/computer?ComputerName=$computerName&UUID=",$UUID,"&SOVersion=",$SOVersion,"&SOCaption=",$SOData.Caption,"&SOBit=",$SOData.OsArchitecture.Substring(0,2),"&LastConnection=",$Timestamp,"&RAM=",$RAMInstalled,"&CPUName=",$CPUInfo.Name)
|
||||
Invoke-RestMethod -Method Get -Uri $paramInvoke | out-null
|
||||
# More info
|
||||
$CPUInfo = (Get-CimInstance Win32_Processor) | Select Name,MaxClockSpeed,ThreadCount
|
||||
$CPUName = -join($CPUInfo.ThreadCount, " x ",$CPUInfo.Name.Trim()," (",$CPUInfo.MaxClockSpeed," MHz)")
|
||||
$RAMInstalled = Get-CimInstance CIM_PhysicalMemory | Measure-Object -Property capacity -Sum | ForEach-Object {[math]::round(($_.sum / 1MB),2)}
|
||||
$RAMFree = [Math]::Round((Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory/1024,0)
|
||||
$RAMUsed = $RamInstalled-$RAMFree
|
||||
# Disks
|
||||
$objDisks = Get-CimInstance -Class win32_LogicalDisk -Filter "DriveType = '3'"
|
||||
$diskResults = @()
|
||||
ForEach( $disk in $objDisks )
|
||||
{
|
||||
$ThisVolume = "" | select Volume,Capacity,FreeSpace
|
||||
$ThisVolume.Volume = $disk.DeviceID
|
||||
$ThisVolume.Capacity = $([Math]::Round($disk.Size / 1GB,2))
|
||||
$ThisVolume.FreeSpace = $([Math]::Round($disk.FreeSpace / 1GB,2))
|
||||
$DiskResults += $ThisVolume
|
||||
}
|
||||
$DisksData = $DiskResults |ConvertTo-Json
|
||||
$DisksData = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($DisksData)) #I can't enter to database all without encode
|
||||
$lastUser = (Get-CimInstance -ClassName Win32_ComputerSystem -Property UserName -ComputerName .).UserName
|
||||
Invoke-RestMethod -Method Get -Uri "$server/upd/computer?ComputerName=$computerName&UUID=$UUID&LastUser=$lastUser" | out-null
|
||||
# Send it
|
||||
$paramInvoke = -join("$server/upd/computer?ComputerName=$computerName&UUID=",$UUID,"&SOVersion=",$SOVersion,"&SOCaption=",$SOData.Caption,"&SOBit=",$SOData.OsArchitecture.Substring(0,2),"&LastConnection=",$Timestamp,"&RAM=",$RAMInstalled,"&RAMFree=",$RAMFree,"&CPUName=",$CPUName,"&LastUser=",$lastUser,"&HDD=",$DisksData)
|
||||
Invoke-RestMethod -Method Get -Uri $paramInvoke | out-null
|
||||
|
||||
# More info (Only if has to be)
|
||||
# $paramInvoke = -join("$server/upd/computerhis?ComputerName=$computerName&UUID=",$UUID,"&RAMFree=",$RAMFree,"&RAMUsed=",$RAMUsed,"&Timestamp=",$Timestamp,"&DisksUse=",$disksUse)
|
||||
# Invoke-RestMethod -Method Get -Uri $paramInvoke | out-null
|
||||
|
||||
|
||||
# Load Cooks of computer
|
||||
$cooks = Invoke-RestMethod -Method Get -Uri "$server/get/cookpend?ComputerName=$computerName&UUID=$UUID"
|
||||
|
||||
foreach ($CookName in $cooks){
|
||||
|
||||
Reference in New Issue
Block a user