-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGet-ComputerStatus.ps1
28 lines (26 loc) · 1.08 KB
/
Get-ComputerStatus.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function Get-ComputerStatus {
[CmdletBinding()]
param (
[Parameter(HelpMessage = "ComputerName to check",Position=0,ValueFromPipeline)]
[Alias("Computer")]
[string]$computerName
)
begin{}
process{
$memory = $(Get-WmiObject -Class WIN32_OperatingSystem -ComputerName $computerName)
$memoryPercentage = [math]::round((($memory.TotalVisibleMemorySize - $memory.FreePhysicalMemory)*100)/ $memory.TotalVisibleMemorySize,5)
$processList = Get-WmiObject WIN32_PROCESS -ComputerName $computerName | Sort-Object -Property ws -Descending | Select-Object -first 5 processname, @{Name="Mem Usage(MB)";Expression={[math]::round($_.ws / 1mb)}}
[PSCustomObject]@{
COMPUTERNAME = $computerName
CONNECTION = $(Test-Path "\\$computerName\C$")
PROCENT_PAMIECI=$memoryPercentage
LISTA_PROCESOW=$processList
}
}
end{}
}
while($true)
{
Write-Host "$(Get-Date -Format "HH:mm_dd.MM.yyyy")" -ForegroundColor Green
Get-Content -Path "D:\lista_stacji.txt" | Get-ComputerStatus
}