Get-Content C:\ps\lista.txt | foreach {
" ======================================== "
" ======================================== "
" "
$ip = $ips = [Net.Dns]::GetHostAddresses("$PSItem") |
Where-Object { $_.AddressFamily -eq 'InterNetwork' } |
Select-Object -Expand IPAddressToString
" 1. = = = = = = = = "
" "
"Badany host to: $PSItem - $ip"
$uptime = Get-WmiObject win32_operatingsystem -ComputerName $PSItem |
select @{n='Nazwa hosta';e={$PSItem.csname}},
@{LABEL='Ostatni restart';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
" "
" 2. = = = = = = = = "
" "
" Ostatni restart :"
$uptime
" "
" 3. = = = = = = = = "
" "
"Zajętość dysków maszyny $PSItem : "
Get-CimInstance -ClassName Win32_LogicalDisk -ComputerName $PSItem |
Where-Object DriveType -eq 3 |
Format-Table @{n='Litera dysku';e={$PSItem.DeviceID}},
@{n='Wielkosc dysku(GB)';e={$PSItem.Size / 1GB};formatString='N2'},
@{n='Uzycie %';e={($PSItem.freespace / $PSItem.size)*100};formatString='N2'} -AutoSize
" 4. = = = = = = = = "
" "
" Error dziennika System: "
Get-EventLog -LogName System -EntryType "Error" -Computername "$PSItem" -newest 10 |
Sort-Object TimeGenerated -Descending -ErrorAction SilentlyContinue
" "
" Error dziennika Security : "
Get-EventLog -LogName Security -EntryType "Error" -Computername "$PSItem" -newest 10 |
Sort-Object TimeGenerated -Descending -ErrorAction SilentlyContinue
" 5. = = = = = = = = "
" "
"Uzycie procesora $PSItem :"
Get-Counter -ComputerName $PSItem '\Process(*)\% Processor Time' `
| Select-Object -ExpandProperty countersamples `
| Select-Object -Property instancename, cookedvalue `
| Sort-Object -Property cookedvalue -Descending | Select-Object -First 10 `
| ft InstanceName,@{L='CPU';E={($_.Cookedvalue/100).toString('P')}} -AutoSize
" "
" 6. = = = = = = = = "
" "
" Wokorzystanie pamieci RAM dla $PSItem : "
$os = Get-Ciminstance Win32_OperatingSystem -ComputerName $PSItem
$pctFree = [math]::Round(($os.FreePhysicalMemory/$os.TotalVisibleMemorySize)*100,2)
if ($pctFree -ge 45) {
$Status = "OK"
}
elseif ($pctFree -ge 15 ) {
$Status = "Warning"
}
else {
$Status = "Critical"
}
$os | Select @{Name = "Status";Expression = {$Status}},
@{Name = "Wolna pamiec %"; Expression = {$pctFree}},
@{Name = "Wolna pamiec GB";Expression = {[math]::Round($_.FreePhysicalMemory/1mb,2)}},
@{Name = "Calkowita pamiec GB";Expression = {[int]($_.TotalVisibleMemorySize/1mb)}}
" "
" "
" ======================================== "
" ======================================== "
}