Added modules from WinAPI
This commit is contained in:
parent
56da334ea2
commit
b709d7e96b
24 changed files with 657 additions and 125 deletions
|
|
@ -2,17 +2,23 @@ function Find-Process {
|
|||
param (
|
||||
$ProcessName
|
||||
)
|
||||
$ProcessPath = (Get-ChildItem "C:\Program Files" | Where-Object Name -match $ProcessName).FullName
|
||||
if ($null -eq $ProcessPath) {
|
||||
$ProcessPath = (Get-ChildItem "C:\Program Files (x86)" | Where-Object Name -match $ProcessName).FullName
|
||||
$PathSearchArray = @(
|
||||
"$env:SystemDrive\Program Files",
|
||||
"$env:SystemDrive\Program Files (x86)",
|
||||
"$env:HOMEPATH\AppData\Roaming",
|
||||
"$env:HOMEPATH\Documents"
|
||||
)
|
||||
foreach ($PathSearch in $PathSearchArray) {
|
||||
$ProcessPath = (Get-ChildItem $PathSearch | Where-Object Name -match $ProcessName).FullName
|
||||
if ($null -ne $ProcessPath) {
|
||||
break
|
||||
}
|
||||
}
|
||||
if ($null -eq $ProcessPath) {
|
||||
$ProcessPath = (Get-ChildItem "C:\Users\lifailon\AppData\Roaming" | Where-Object Name -match $ProcessName).FullName
|
||||
}
|
||||
$ProcessNameExec = "$ProcessName"+".exe"
|
||||
$ProcessNameExec = "$($ProcessName).exe"
|
||||
(Get-ChildItem $ProcessPath -Recurse | Where-Object Name -eq $ProcessNameExec).FullName
|
||||
}
|
||||
|
||||
# Find-Process OpenHardwareMonitor # C:\Users\lifailon\Documents\OpenHardwareMonitor-0.9.6\OpenHardwareMonitor-0.9.6\OpenHardwareMonitor.exe
|
||||
# Find-Process qbittorrent # C:\Program Files\qBittorrent\qbittorrent.exe
|
||||
# Find-Process nmap # C:\Program Files (x86)\Nmap\nmap.exe
|
||||
# Find-Process telegram # C:\Users\lifailon\AppData\Roaming\Telegram Desktop\Telegram.exe
|
||||
12
Scripts/Get-CPU.psm1
Normal file
12
Scripts/Get-CPU.psm1
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
function Get-CPU {
|
||||
$CPU_Perf = Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor
|
||||
$CPU_Cores = $CPU_Perf | Where-Object Name -ne "_Total" | Sort-Object {[int]$_.Name}
|
||||
$CPU_Total = $CPU_Perf | Where-Object Name -eq "_Total"
|
||||
$CPU_All = $CPU_Cores + $CPU_Total
|
||||
$CPU_All | Select-Object Name,
|
||||
@{Label="ProcessorTime"; Expression={[String]$_.PercentProcessorTime+" %"}},
|
||||
@{Label="PrivilegedTime"; Expression={[String]$_.PercentPrivilegedTime+" %"}},
|
||||
@{Label="UserTime"; Expression={[String]$_.PercentUserTime+" %"}},
|
||||
@{Label="InterruptTime"; Expression={[String]$_.PercentInterruptTime+" %"}},
|
||||
@{Label="IdleTime"; Expression={[String]$_.PercentIdleTime+" %"}}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
function Get-CPUse {
|
||||
$CPU_Use_Proc = [string]((Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor -ErrorAction Ignore |
|
||||
Where-Object name -eq "_Total").PercentProcessorTime)+" %"
|
||||
$CollectionCPU = New-Object System.Collections.Generic.List[System.Object]
|
||||
$CollectionCPU.Add([PSCustomObject]@{
|
||||
CPU = $CPU_Use_Proc
|
||||
})
|
||||
$CollectionCPU
|
||||
}
|
||||
|
|
@ -1,9 +1,12 @@
|
|||
function Get-LD {
|
||||
$LogicalDisk = Get-CimInstance Win32_logicalDisk | Where-Object {$null -ne $_.Size} | Select-Object @{
|
||||
Label="Value"; Expression={$_.DeviceID}}, @{Label="AllSize"; Expression={
|
||||
([int]($_.Size/1Gb))}},@{Label="FreeSize"; Expression={
|
||||
([int]($_.FreeSpace/1Gb))}}, @{Label="Free%"; Expression={
|
||||
[string]([int]($_.FreeSpace/$_.Size*100))+" %"}},FileSystem,VolumeName
|
||||
function Get-DiskLogical {
|
||||
$LogicalDisk = Get-CimInstance Win32_logicalDisk | Where-Object {$null -ne $_.Size} |
|
||||
Select-Object @{Label="Value"; Expression={$_.DeviceID}},
|
||||
@{Label="AllSize"; Expression={([int]($_.Size/1Gb))}},
|
||||
@{Label="FreeSize"; Expression={([int]($_.FreeSpace/1Gb))}},
|
||||
@{Label="Free%"; Expression={
|
||||
[string]([int]($_.FreeSpace/$_.Size*100))+" %"}},
|
||||
FileSystem,
|
||||
VolumeName
|
||||
$CollectionLD = New-Object System.Collections.Generic.List[System.Object]
|
||||
$LogicalDisk | ForEach-Object {
|
||||
$CollectionLD.Add([PSCustomObject]@{
|
||||
13
Scripts/Get-DiskPartition.psm1
Normal file
13
Scripts/Get-DiskPartition.psm1
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function Get-DiskPartition {
|
||||
$PhysicalDisk = Get-CimInstance -Namespace root/Microsoft/Windows/Storage -ClassName MSFT_PhysicalDisk
|
||||
$Partition = Get-CimInstance -Namespace root/Microsoft/Windows/Storage -ClassName MSFT_Partition |
|
||||
Select-Object @{Label="Disk"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DiskNumber | Select-Object -ExpandProperty FriendlyName}},
|
||||
IsBoot,
|
||||
IsSystem,
|
||||
IsHidden,
|
||||
IsReadOnly,
|
||||
IsShadowCopy,
|
||||
@{Label="OffSet"; Expression={($_.OffSet/1Gb).ToString("0.00 Gb")}},
|
||||
@{Label="Size"; Expression={($_.Size/1Gb).ToString("0.00 Gb")}}
|
||||
$Partition | Sort-Object Disk,OffSet
|
||||
}
|
||||
23
Scripts/Get-DiskPhysical.psm1
Normal file
23
Scripts/Get-DiskPhysical.psm1
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
function Get-DiskPhysical {
|
||||
$PhysicalDisk = Get-CimInstance Win32_DiskDrive |
|
||||
Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}},
|
||||
Partitions,
|
||||
InterfaceType,
|
||||
Status,
|
||||
ConfigManagerErrorCode,
|
||||
LastErrorCode
|
||||
$CollectionPD = New-Object System.Collections.Generic.List[System.Object]
|
||||
$PhysicalDisk | ForEach-Object {
|
||||
$CollectionPD.Add([PSCustomObject]@{
|
||||
Model = $_.Model
|
||||
Size = [string]$_.Size+" Gb"
|
||||
PartitionCount = $_.Partitions
|
||||
Interface = $_.InterfaceType
|
||||
Status = $_.Status
|
||||
ConfigManagerErrorCode = $_.ConfigManagerErrorCode
|
||||
LastErrorCode = $_.LastErrorCode
|
||||
})
|
||||
}
|
||||
$CollectionPD
|
||||
}
|
||||
7
Scripts/Get-Driver.psm1
Normal file
7
Scripts/Get-Driver.psm1
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function Get-Driver {
|
||||
Get-CimInstance -Class Win32_PnPSignedDriver | Select-Object DriverProviderName,
|
||||
FriendlyName,
|
||||
Description,
|
||||
DriverVersion,
|
||||
DriverDate
|
||||
}
|
||||
21
Scripts/Get-Event.psm1
Normal file
21
Scripts/Get-Event.psm1
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
function Get-Event {
|
||||
param (
|
||||
[string]$LogName,
|
||||
[switch]$List
|
||||
)
|
||||
if ($List) {
|
||||
Get-WinEvent -ListLog * | Where-Object RecordCount -gt 0 |
|
||||
Select-Object RecordCount,
|
||||
@{Name="LastWriteTime"; Expression={Get-Date -Date $($_.LastWriteTime) -UFormat "%d.%m.%Y %T"}},
|
||||
@{Name="FileSize"; Expression={($_.FileSize / 1024kb).ToString("0.00 Mb")}},
|
||||
LogIsolation,
|
||||
LogType,
|
||||
LogName | Sort-Object LogIsolation
|
||||
}
|
||||
else {
|
||||
Get-WinEvent -LogName $LogName | Select-Object @{Name="TimeCreated"; Expression={Get-Date -Date $($_.TimeCreated) -UFormat "%d.%m.%Y %T"}},
|
||||
LevelDisplayName,
|
||||
Level,
|
||||
Message
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,8 @@
|
|||
Import-Module ThreadJob -ErrorAction Ignore
|
||||
if (!(Get-Module ThreadJob)) {
|
||||
Install-Module ThreadJob -Scope CurrentUser -Force
|
||||
}
|
||||
|
||||
function Get-Hardware {
|
||||
param (
|
||||
$ComputerName,
|
||||
|
|
@ -6,51 +11,89 @@ function Get-Hardware {
|
|||
$Pass = "api"
|
||||
)
|
||||
if ($null -eq $ComputerName) {
|
||||
$Collection = New-Object System.Collections.Generic.List[System.Object]
|
||||
$SYS = Get-CimInstance Win32_ComputerSystem
|
||||
$BootTime = Get-CimInstance -ComputerName $srv Win32_OperatingSystem | Select-Object LocalDateTime,LastBootUpTime
|
||||
$Uptime = ([string]($BootTime.LocalDateTime - $BootTime.LastBootUpTime) -split ":")[0,1] -join ":"
|
||||
$BootDate = Get-Date -Date $BootTime.LastBootUpTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||
$OS = Get-CimInstance Win32_OperatingSystem
|
||||
$BB = Get-CimInstance Win32_BaseBoard
|
||||
# Creat jobs
|
||||
Start-ThreadJob -Name SYS -ScriptBlock {Get-CimInstance Win32_ComputerSystem} | Out-Null
|
||||
Start-ThreadJob -Name OS -ScriptBlock {Get-CimInstance Win32_OperatingSystem} | Out-Null
|
||||
Start-ThreadJob -Name BB -ScriptBlock {Get-CimInstance Win32_BaseBoard} | Out-Null
|
||||
Start-ThreadJob -Name CPU -ScriptBlock {Get-CimInstance Win32_Processor} | Out-Null
|
||||
Start-ThreadJob -Name CPU_Use -ScriptBlock {Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor} | Out-Null
|
||||
Start-ThreadJob -Name GetProcess -ScriptBlock {Get-Process} | Out-Null
|
||||
Start-ThreadJob -Name MEM -ScriptBlock {Get-CimInstance Win32_PhysicalMemory} | Out-Null
|
||||
Start-ThreadJob -Name PhysicalDisk -ScriptBlock {Get-CimInstance Win32_DiskDrive} | Out-Null
|
||||
Start-ThreadJob -Name LogicalDisk -ScriptBlock {Get-CimInstance Win32_logicalDisk} | Out-Null
|
||||
Start-ThreadJob -Name IOps -ScriptBlock {Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk} | Out-Null
|
||||
Start-ThreadJob -Name VideoCard -ScriptBlock {Get-CimInstance Win32_VideoController} | Out-Null
|
||||
Start-ThreadJob -Name NetworkAdapter -ScriptBlock {Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true} | Out-Null
|
||||
Start-ThreadJob -Name InterfaceStatCurrent -ScriptBlock {Get-CimInstance -ClassName Win32_PerfFormattedData_Tcpip_NetworkInterface} | Out-Null
|
||||
Start-ThreadJob -Name InterfaceStatAll -ScriptBlock {Get-CimInstance -ClassName Win32_PerfRawData_Tcpip_NetworkInterface} | Out-Null
|
||||
# Get data from jobs
|
||||
Start-Sleep -Milliseconds 100
|
||||
while ($(Get-Job).State -contains "Running") {
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
$SYS = Get-Job -Name SYS | Receive-Job
|
||||
$OS = Get-Job -Name OS | Receive-Job
|
||||
$BB = Get-Job -Name BB | Receive-Job
|
||||
$CPU = Get-Job -Name CPU | Receive-Job
|
||||
$CPU_Use = Get-Job -Name CPU_Use | Receive-Job
|
||||
$GetProcess = Get-Job -Name GetProcess | Receive-Job
|
||||
$MEM = Get-Job -Name MEM | Receive-Job
|
||||
$PhysicalDisk = Get-Job -Name PhysicalDisk | Receive-Job
|
||||
$LogicalDisk = Get-Job -Name LogicalDisk | Receive-Job
|
||||
$IOps = Get-Job -Name IOps | Receive-Job
|
||||
$VideoCard = Get-Job -Name VideoCard | Receive-Job
|
||||
$NetworkAdapter = Get-Job -Name NetworkAdapter | Receive-Job
|
||||
$InterfaceStatCurrent = Get-Job -Name InterfaceStatCurrent | Receive-Job
|
||||
$InterfaceStatAll = Get-Job -Name InterfaceStatAll | Receive-Job
|
||||
Get-Job | Remove-Job -Force
|
||||
# Select data
|
||||
$Uptime = ([string]($OS.LocalDateTime - $OS.LastBootUpTime) -split ":")[0,1] -join ":"
|
||||
$BootDate = Get-Date -Date $($OS).LastBootUpTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||
$BBv = $BB.Manufacturer+" "+$BB.Product+" "+$BB.Version
|
||||
$CPU = Get-CimInstance Win32_Processor | Select-Object Name,
|
||||
@{Label="Core"; Expression={$_.NumberOfCores}},
|
||||
@{Label="Thread"; Expression={$_.NumberOfLogicalProcessors}}
|
||||
$CPU_Use_Proc = [string]((Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor -ErrorAction Ignore |
|
||||
Where-Object name -eq "_Total").PercentProcessorTime)+" %"
|
||||
$GetProcess = Get-Process
|
||||
$CPU = $CPU | Select-Object Name,
|
||||
@{Label="Core"; Expression={$_.NumberOfCores}},
|
||||
@{Label="Thread"; Expression={$_.NumberOfLogicalProcessors}}
|
||||
$CPU_Use_Proc = [string](($CPU_Use | Where-Object name -eq "_Total").PercentProcessorTime)+" %"
|
||||
$Process_Count = $GetProcess.Count
|
||||
$Threads_Count = $GetProcess.Threads.Count
|
||||
$Handles_Count = ($GetProcess.Handles | Measure-Object -Sum).Sum
|
||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$pm = ((($GetProcess).PM | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
|
||||
$MEM = Get-CimInstance Win32_PhysicalMemory | Select-Object Manufacturer,PartNumber,
|
||||
ConfiguredClockSpeed,@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
||||
$MemUse = $OS.TotalVisibleMemorySize - $OS.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $OS.TotalVisibleMemorySize) * 100
|
||||
$MEM = $MEM | Select-Object Manufacturer,PartNumber,ConfiguredClockSpeed,
|
||||
@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
||||
$MEMs = $MEM.Memory | Measure-Object -Sum
|
||||
$PhysicalDisk = Get-CimInstance Win32_DiskDrive | Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}}
|
||||
$PhysicalDisk = $PhysicalDisk | Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}}
|
||||
$PDs = $PhysicalDisk.Size | Measure-Object -Sum
|
||||
$LogicalDisk = Get-CimInstance Win32_logicalDisk | Where-Object {$null -ne $_.Size} | Select-Object @{
|
||||
Label="Value"; Expression={$_.DeviceID}}, @{Label="AllSize"; Expression={
|
||||
([int]($_.Size/1Gb))}},@{Label="FreeSize"; Expression={
|
||||
([int]($_.FreeSpace/1Gb))}}, @{Label="Free%"; Expression={
|
||||
[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
|
||||
$LogicalDisk = $LogicalDisk | Where-Object {$null -ne $_.Size} |
|
||||
Select-Object @{Label="Value"; Expression={$_.DeviceID}},
|
||||
@{Label="AllSize"; Expression={([int]($_.Size/1Gb))}},
|
||||
@{Label="FreeSize"; Expression={([int]($_.FreeSpace/1Gb))}},
|
||||
@{Label="Free%"; Expression={[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
|
||||
$LDs = $LogicalDisk.AllSize | Measure-Object -Sum
|
||||
$IOps = Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk -ErrorAction Ignore |
|
||||
Where-Object { $_.Name -eq "_Total" } | Select-Object Name,PercentDiskTime,PercentIdleTime,
|
||||
PercentDiskWriteTime,PercentDiskReadTime,CurrentDiskQueueLength,DiskBytesPersec,DiskReadBytesPersec,
|
||||
DiskReadsPersec,DiskTransfersPersec,DiskWriteBytesPersec,DiskWritesPersec
|
||||
$VideoCard = Get-CimInstance Win32_VideoController | Select-Object @{
|
||||
Label="VideoCard"; Expression={$_.Name}}, @{Label="Display"; Expression={
|
||||
[string]$_.CurrentHorizontalResolution+"x"+[string]$_.CurrentVerticalResolution}},
|
||||
@{Label="vRAM"; Expression={($_.AdapterRAM/1Gb)}}
|
||||
$IOps = $IOps | Where-Object { $_.Name -eq "_Total" } | Select-Object Name,
|
||||
@{name="TotalTime";expression={"$($_.PercentDiskTime) %"}},
|
||||
@{name="IOps";expression={$_.DiskTransfersPersec}},
|
||||
@{name="ReadBytesPersec";expression={$($_.DiskReadBytesPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="WriteBytesPersec";expression={$($_.DiskWriteBytesPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$VideoCard = $VideoCard | Select-Object @{Label="VideoCard"; Expression={$_.Name}},
|
||||
@{Label="Display"; Expression={[string]$_.CurrentHorizontalResolution+"x"+[string]$_.CurrentVerticalResolution}},
|
||||
@{Label="vRAM"; Expression={([int]$($_.AdapterRAM/1Gb))}}
|
||||
$VCs = $VideoCard.vRAM | Measure-Object -Sum
|
||||
$NetworkAdapter = Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true
|
||||
$NAs = $NetworkAdapter | Measure-Object
|
||||
$InterfaceStatCurrent = $InterfaceStatCurrent | Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$InterfaceStatAll = $InterfaceStatAll | Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1gb).ToString("0.00 GByte")}}
|
||||
$PortListenCount = $(Get-NetTCPConnection -State Listen).Count
|
||||
$PortEstablishedCount = $(Get-NetTCPConnection -State Established).Count
|
||||
$Collection = New-Object System.Collections.Generic.List[System.Object]
|
||||
$Collection.Add([PSCustomObject]@{
|
||||
Host = $SYS.Name
|
||||
Uptime = $uptime
|
||||
|
|
@ -75,10 +118,19 @@ function Get-Hardware {
|
|||
PhysicalDiskAllSize = [string]$PDs.Sum+" Gb"
|
||||
LogicalDiskCount = $LDs.Count
|
||||
LogicalDiskAllSize = [string]$LDs.Sum+" Gb"
|
||||
DiskTotalTime = [string]$IOps.PercentDiskTime+" %"
|
||||
DiskTotalTime = $IOps.TotalTime
|
||||
DiskTotalIOps = $IOps.IOps
|
||||
DiskTotalRead = $IOps.ReadBytesPersec
|
||||
DiskTotalWrite = $IOps.WriteBytesPersec
|
||||
VideoCardCount = $VCs.Count
|
||||
VideoCardAllSize = [string]$VCs.Sum+" Gb"
|
||||
NetworkAdapterEnableCount = $NAs.Count
|
||||
NetworkReceivedCurrent = $InterfaceStatCurrent.Received
|
||||
NetworkSentCurrent = $InterfaceStatCurrent.Sent
|
||||
NetworkReceivedTotal = $InterfaceStatAll.Received
|
||||
NetworkSentTotal = $InterfaceStatAll.Sent
|
||||
PortListenCount = $PortListenCount
|
||||
PortEstablishedCount = $PortEstablishedCount
|
||||
})
|
||||
$Collection
|
||||
}
|
||||
|
|
|
|||
126
Scripts/Get-HardwareNoJob.psm1
Normal file
126
Scripts/Get-HardwareNoJob.psm1
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
function Get-HardwareNoJob {
|
||||
param (
|
||||
$ComputerName,
|
||||
$Port = 8443,
|
||||
$User = "rest",
|
||||
$Pass = "api"
|
||||
)
|
||||
if ($null -eq $ComputerName) {
|
||||
$Collection = New-Object System.Collections.Generic.List[System.Object]
|
||||
$SYS = Get-CimInstance Win32_ComputerSystem
|
||||
$BootTime = Get-CimInstance -ComputerName $srv Win32_OperatingSystem |
|
||||
Select-Object LocalDateTime,
|
||||
LastBootUpTime
|
||||
$Uptime = ([string]($BootTime.LocalDateTime - $BootTime.LastBootUpTime) -split ":")[0,1] -join ":"
|
||||
$BootDate = Get-Date -Date $BootTime.LastBootUpTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||
$OS = Get-CimInstance Win32_OperatingSystem
|
||||
$BB = Get-CimInstance Win32_BaseBoard
|
||||
$BBv = $BB.Manufacturer+" "+$BB.Product+" "+$BB.Version
|
||||
$CPU = Get-CimInstance Win32_Processor |
|
||||
Select-Object Name,
|
||||
@{Label="Core"; Expression={$_.NumberOfCores}},
|
||||
@{Label="Thread"; Expression={$_.NumberOfLogicalProcessors}}
|
||||
$CPU_Use_Proc = [string]((Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor -ErrorAction Ignore |
|
||||
Where-Object name -eq "_Total").PercentProcessorTime)+" %"
|
||||
$GetProcess = Get-Process
|
||||
$Process_Count = $GetProcess.Count
|
||||
$Threads_Count = $GetProcess.Threads.Count
|
||||
$Handles_Count = ($GetProcess.Handles | Measure-Object -Sum).Sum
|
||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$pm = ((($GetProcess).PM | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
|
||||
$MEM = Get-CimInstance Win32_PhysicalMemory |
|
||||
Select-Object Manufacturer,
|
||||
PartNumber,
|
||||
ConfiguredClockSpeed,@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
||||
$MEMs = $MEM.Memory | Measure-Object -Sum
|
||||
$PhysicalDisk = Get-CimInstance Win32_DiskDrive |
|
||||
Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}}
|
||||
$PDs = $PhysicalDisk.Size | Measure-Object -Sum
|
||||
$LogicalDisk = Get-CimInstance Win32_logicalDisk | Where-Object {$null -ne $_.Size} |
|
||||
Select-Object @{Label="Value"; Expression={$_.DeviceID}},
|
||||
@{Label="AllSize"; Expression={([int]($_.Size/1Gb))}},
|
||||
@{Label="FreeSize"; Expression={([int]($_.FreeSpace/1Gb))}},
|
||||
@{Label="Free%"; Expression={[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
|
||||
$LDs = $LogicalDisk.AllSize | Measure-Object -Sum
|
||||
$IOps = Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk -ErrorAction Ignore |
|
||||
Where-Object { $_.Name -eq "_Total" } |
|
||||
Select-Object Name,
|
||||
@{name="TotalTime";expression={"$($_.PercentDiskTime) %"}},
|
||||
@{name="IOps";expression={$_.DiskTransfersPersec}},
|
||||
@{name="ReadBytesPersec";expression={$($_.DiskReadBytesPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="WriteBytesPersec";expression={$($_.DiskWriteBytesPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$VideoCard = Get-CimInstance Win32_VideoController |
|
||||
Select-Object @{Label="VideoCard"; Expression={$_.Name}},
|
||||
@{Label="Display"; Expression={[string]$_.CurrentHorizontalResolution+"x"+[string]$_.CurrentVerticalResolution}},
|
||||
@{Label="vRAM"; Expression={([int]$($_.AdapterRAM/1Gb))}}
|
||||
$VCs = $VideoCard.vRAM | Measure-Object -Sum
|
||||
$NetworkAdapter = Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true
|
||||
$NAs = $NetworkAdapter | Measure-Object
|
||||
$InterfaceStatCurrent = Get-CimInstance -ClassName Win32_PerfFormattedData_Tcpip_NetworkInterface |
|
||||
Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$InterfaceStatAll = Get-CimInstance -ClassName Win32_PerfRawData_Tcpip_NetworkInterface |
|
||||
Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1gb).ToString("0.00 GByte")}}
|
||||
$PortListenCount = $(Get-NetTCPConnection -State Listen).Count
|
||||
$PortEstablishedCount = $(Get-NetTCPConnection -State Established).Count
|
||||
$Collection.Add([PSCustomObject]@{
|
||||
Host = $SYS.Name
|
||||
Uptime = $uptime
|
||||
BootDate = $BootDate
|
||||
Owner = $SYS.PrimaryOwnerName
|
||||
OS = $OS.Caption
|
||||
Motherboard = $BBv
|
||||
Processor = $CPU[0].Name
|
||||
Core = $CPU[0].Core
|
||||
Thread = $CPU[0].Thread
|
||||
CPU = $CPU_Use_Proc
|
||||
ProcessCount = $Process_Count
|
||||
ThreadsCount = $Threads_Count
|
||||
HandlesCount = [int]$Handles_Count
|
||||
MemoryAll = [string]$($MEMs.Sum/1Kb)+" GB"
|
||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||
WorkingSet = $ws
|
||||
PageMemory = $pm
|
||||
MemorySlots = $MEMs.Count
|
||||
PhysicalDiskCount = $PDs.Count
|
||||
PhysicalDiskAllSize = [string]$PDs.Sum+" Gb"
|
||||
LogicalDiskCount = $LDs.Count
|
||||
LogicalDiskAllSize = [string]$LDs.Sum+" Gb"
|
||||
DiskTotalTime = $IOps.TotalTime
|
||||
DiskTotalIOps = $IOps.IOps
|
||||
DiskTotalRead = $IOps.ReadBytesPersec
|
||||
DiskTotalWrite = $IOps.WriteBytesPersec
|
||||
VideoCardCount = $VCs.Count
|
||||
VideoCardAllSize = [string]$VCs.Sum+" Gb"
|
||||
NetworkAdapterEnableCount = $NAs.Count
|
||||
NetworkReceivedCurrent = $InterfaceStatCurrent.Received
|
||||
NetworkSentCurrent = $InterfaceStatCurrent.Sent
|
||||
NetworkReceivedTotal = $InterfaceStatAll.Received
|
||||
NetworkSentTotal = $InterfaceStatAll.Sent
|
||||
PortListenCount = $PortListenCount
|
||||
PortEstablishedCount = $PortEstablishedCount
|
||||
})
|
||||
$Collection
|
||||
}
|
||||
else {
|
||||
$url = "http://$ComputerName"+":$Port/api/hardware"
|
||||
$EncodingCred = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("${User}:${Pass}"))
|
||||
$Headers = @{"Authorization" = "Basic ${EncodingCred}"}
|
||||
try {
|
||||
Invoke-RestMethod -Headers $Headers -Uri $url
|
||||
}
|
||||
catch {
|
||||
Write-Error "Error connection"
|
||||
}
|
||||
}
|
||||
}
|
||||
149
Scripts/Get-HardwareRSJob.psm1
Normal file
149
Scripts/Get-HardwareRSJob.psm1
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
Import-Module PoshRSJob -ErrorAction Ignore
|
||||
if (!(Get-Module PoshRSJob)) {
|
||||
Install-Module PoshRSJob -Scope CurrentUser -Force
|
||||
}
|
||||
|
||||
function Get-HardwareRSJob {
|
||||
param (
|
||||
$ComputerName,
|
||||
$Port = 8443,
|
||||
$User = "rest",
|
||||
$Pass = "api"
|
||||
)
|
||||
i
|
||||
f ($null -eq $ComputerName) {
|
||||
# Creat jobs
|
||||
Start-RSJob -Name SYS -ScriptBlock {Get-CimInstance Win32_ComputerSystem} | Out-Null
|
||||
Start-RSJob -Name OS -ScriptBlock {Get-CimInstance Win32_OperatingSystem} | Out-Null
|
||||
Start-RSJob -Name BB -ScriptBlock {Get-CimInstance Win32_BaseBoard} | Out-Null
|
||||
Start-RSJob -Name CPU -ScriptBlock {Get-CimInstance Win32_Processor} | Out-Null
|
||||
Start-RSJob -Name CPU_Use -ScriptBlock {Get-CimInstance Win32_PerfFormattedData_PerfOS_Processor} | Out-Null
|
||||
Start-RSJob -Name GetProcess -ScriptBlock {Get-Process} | Out-Null
|
||||
Start-RSJob -Name MEM -ScriptBlock {Get-CimInstance Win32_PhysicalMemory} | Out-Null
|
||||
Start-RSJob -Name PhysicalDisk -ScriptBlock {Get-CimInstance Win32_DiskDrive} | Out-Null
|
||||
Start-RSJob -Name LogicalDisk -ScriptBlock {Get-CimInstance Win32_logicalDisk} | Out-Null
|
||||
Start-RSJob -Name IOps -ScriptBlock {Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk} | Out-Null
|
||||
Start-RSJob -Name VideoCard -ScriptBlock {Get-CimInstance Win32_VideoController} | Out-Null
|
||||
Start-RSJob -Name NetworkAdapter -ScriptBlock {Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true} | Out-Null
|
||||
Start-RSJob -Name InterfaceStatCurrent -ScriptBlock {Get-CimInstance -ClassName Win32_PerfFormattedData_Tcpip_NetworkInterface} | Out-Null
|
||||
Start-RSJob -Name InterfaceStatAll -ScriptBlock {Get-CimInstance -ClassName Win32_PerfRawData_Tcpip_NetworkInterface} | Out-Null
|
||||
# Get data from jobs
|
||||
Start-Sleep -Milliseconds 100
|
||||
while ($(Get-RSJob).State -contains "Running") {
|
||||
Start-Sleep -Milliseconds 100
|
||||
}
|
||||
$SYS = Get-RSJob -Name SYS | Receive-RSJob
|
||||
$OS = Get-RSJob -Name OS | Receive-RSJob
|
||||
$BB = Get-RSJob -Name BB | Receive-RSJob
|
||||
$CPU = Get-RSJob -Name CPU | Receive-RSJob
|
||||
$CPU_Use = Get-RSJob -Name CPU_Use | Receive-RSJob
|
||||
$GetProcess = Get-RSJob -Name GetProcess | Receive-RSJob
|
||||
$MEM = Get-RSJob -Name MEM | Receive-RSJob
|
||||
$PhysicalDisk = Get-RSJob -Name PhysicalDisk | Receive-RSJob
|
||||
$LogicalDisk = Get-RSJob -Name LogicalDisk | Receive-RSJob
|
||||
$IOps = Get-RSJob -Name IOps | Receive-RSJob
|
||||
$VideoCard = Get-RSJob -Name VideoCard | Receive-RSJob
|
||||
$NetworkAdapter = Get-RSJob -Name NetworkAdapter | Receive-RSJob
|
||||
$InterfaceStatCurrent = Get-RSJob -Name InterfaceStatCurrent | Receive-RSJob
|
||||
$InterfaceStatAll = Get-RSJob -Name InterfaceStatAll | Receive-RSJob
|
||||
Get-RSJob | Remove-RSJob -Force
|
||||
# Select data
|
||||
$Uptime = ([string]($OS.LocalDateTime - $OS.LastBootUpTime) -split ":")[0,1] -join ":"
|
||||
$BootDate = Get-Date -Date $($OS).LastBootUpTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||
$BBv = $BB.Manufacturer+" "+$BB.Product+" "+$BB.Version
|
||||
$CPU = $CPU | Select-Object Name,
|
||||
@{Label="Core"; Expression={$_.NumberOfCores}},
|
||||
@{Label="Thread"; Expression={$_.NumberOfLogicalProcessors}}
|
||||
$CPU_Use_Proc = [string](($CPU_Use | Where-Object name -eq "_Total").PercentProcessorTime)+" %"
|
||||
$Process_Count = $GetProcess.Count
|
||||
$Threads_Count = $GetProcess.Threads.Count
|
||||
$Handles_Count = ($GetProcess.Handles | Measure-Object -Sum).Sum
|
||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$pm = ((($GetProcess).PM | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$MemUse = $OS.TotalVisibleMemorySize - $OS.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $OS.TotalVisibleMemorySize) * 100
|
||||
$MEM = $MEM | Select-Object Manufacturer,PartNumber,ConfiguredClockSpeed,
|
||||
@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
||||
$MEMs = $MEM.Memory | Measure-Object -Sum
|
||||
$PhysicalDisk = $PhysicalDisk | Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}}
|
||||
$PDs = $PhysicalDisk.Size | Measure-Object -Sum
|
||||
$LogicalDisk = $LogicalDisk | Where-Object {$null -ne $_.Size} |
|
||||
Select-Object @{Label="Value"; Expression={$_.DeviceID}},
|
||||
@{Label="AllSize"; Expression={([int]($_.Size/1Gb))}},
|
||||
@{Label="FreeSize"; Expression={([int]($_.FreeSpace/1Gb))}},
|
||||
@{Label="Free%"; Expression={[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
|
||||
$LDs = $LogicalDisk.AllSize | Measure-Object -Sum
|
||||
$IOps = $IOps | Where-Object { $_.Name -eq "_Total" } | Select-Object Name,
|
||||
@{name="TotalTime";expression={"$($_.PercentDiskTime) %"}},
|
||||
@{name="IOps";expression={$_.DiskTransfersPersec}},
|
||||
@{name="ReadBytesPersec";expression={$($_.DiskReadBytesPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="WriteBytesPersec";expression={$($_.DiskWriteBytesPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$VideoCard = $VideoCard | Select-Object @{Label="VideoCard"; Expression={$_.Name}},
|
||||
@{Label="Display"; Expression={[string]$_.CurrentHorizontalResolution+"x"+[string]$_.CurrentVerticalResolution}},
|
||||
@{Label="vRAM"; Expression={([int]$($_.AdapterRAM/1Gb))}}
|
||||
$VCs = $VideoCard.vRAM | Measure-Object -Sum
|
||||
$NAs = $NetworkAdapter | Measure-Object
|
||||
$InterfaceStatCurrent = $InterfaceStatCurrent | Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1mb).ToString("0.000 MByte/Sec")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1mb).ToString("0.000 MByte/Sec")}}
|
||||
$InterfaceStatAll = $InterfaceStatAll | Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1gb).ToString("0.00 GByte")}}
|
||||
$PortListenCount = $(Get-NetTCPConnection -State Listen).Count
|
||||
$PortEstablishedCount = $(Get-NetTCPConnection -State Established).Count
|
||||
$Collection = New-Object System.Collections.Generic.List[System.Object]
|
||||
$Collection.Add([PSCustomObject]@{
|
||||
Host = $SYS.Name
|
||||
Uptime = $uptime
|
||||
BootDate = $BootDate
|
||||
Owner = $SYS.PrimaryOwnerName
|
||||
OS = $OS.Caption
|
||||
Motherboard = $BBv
|
||||
Processor = $CPU[0].Name
|
||||
Core = $CPU[0].Core
|
||||
Thread = $CPU[0].Thread
|
||||
CPU = $CPU_Use_Proc
|
||||
ProcessCount = $Process_Count
|
||||
ThreadsCount = $Threads_Count
|
||||
HandlesCount = [int]$Handles_Count
|
||||
MemoryAll = [string]$($MEMs.Sum/1Kb)+" GB"
|
||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||
WorkingSet = $ws
|
||||
PageMemory = $pm
|
||||
MemorySlots = $MEMs.Count
|
||||
PhysicalDiskCount = $PDs.Count
|
||||
PhysicalDiskAllSize = [string]$PDs.Sum+" Gb"
|
||||
LogicalDiskCount = $LDs.Count
|
||||
LogicalDiskAllSize = [string]$LDs.Sum+" Gb"
|
||||
DiskTotalTime = $IOps.TotalTime
|
||||
DiskTotalIOps = $IOps.IOps
|
||||
DiskTotalRead = $IOps.ReadBytesPersec
|
||||
DiskTotalWrite = $IOps.WriteBytesPersec
|
||||
VideoCardCount = $VCs.Count
|
||||
VideoCardAllSize = [string]$VCs.Sum+" Gb"
|
||||
NetworkAdapterEnableCount = $NAs.Count
|
||||
NetworkReceivedCurrent = $InterfaceStatCurrent.Received
|
||||
NetworkSentCurrent = $InterfaceStatCurrent.Sent
|
||||
NetworkReceivedTotal = $InterfaceStatAll.Received
|
||||
NetworkSentTotal = $InterfaceStatAll.Sent
|
||||
PortListenCount = $PortListenCount
|
||||
PortEstablishedCount = $PortEstablishedCount
|
||||
})
|
||||
$Collection
|
||||
}
|
||||
else {
|
||||
$url = "http://$ComputerName"+":$Port/api/hardware"
|
||||
$EncodingCred = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes("${User}:${Pass}"))
|
||||
$Headers = @{"Authorization" = "Basic ${EncodingCred}"}
|
||||
try {
|
||||
Invoke-RestMethod -Headers $Headers -Uri $url
|
||||
}
|
||||
catch {
|
||||
Write-Error "Error connection"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,14 @@
|
|||
function Get-IOps {
|
||||
Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk -ErrorAction Ignore |
|
||||
Where-Object { $_.Name -ne "_Total" } | Select-Object Name,PercentDiskTime,PercentIdleTime,
|
||||
PercentDiskWriteTime,PercentDiskReadTime,CurrentDiskQueueLength,DiskBytesPersec,DiskReadBytesPersec,
|
||||
DiskReadsPersec,DiskTransfersPersec,DiskWriteBytesPersec,DiskWritesPersec
|
||||
Get-CimInstance Win32_PerfFormattedData_PerfDisk_PhysicalDisk | Select-Object Name,
|
||||
@{name="ReadWriteTime";expression={"$($_.PercentDiskTime) %"}}, # Процент времени, в течение которого физический диск занят обработкой запросов ввода-вывода
|
||||
@{name="ReadTime";expression={"$($_.PercentDiskReadTime) %"}}, # Процент времени, в течение которого физический диск занят чтением данных
|
||||
@{name="WriteTime";expression={"$($_.PercentDiskWriteTime) %"}}, # Процент времени, в течение которого физический диск занят записью данных
|
||||
@{name="IdleTime";expression={"$($_.PercentIdleTime) %"}}, # Процент времени, в течение которого физический диск не занят (находится в режиме простоя)
|
||||
@{name="QueueLength";expression={$_.CurrentDiskQueueLength}}, # Текущая длина очереди диска (количество запросов, которые ожидают обработки диском)
|
||||
@{name="BytesPersec";expression={$($_.DiskBytesPersec/1mb).ToString("0.000 MByte/Sec")}}, # Скорость передачи данных через диск в байтах в секунду (объединенное значение для чтения и записи)
|
||||
@{name="ReadBytesPersec";expression={$($_.DiskReadBytesPersec/1mb).ToString("0.000 MByte/Sec")}}, # Скорость чтения данных с диска в байтах в секунду
|
||||
@{name="WriteBytesPersec";expression={$($_.DiskWriteBytesPersec/1mb).ToString("0.000 MByte/Sec")}}, # Скорость записи данных на диск в байтах в секунду
|
||||
@{name="IOps";expression={$_.DiskTransfersPersec}}, # Общее количество операций ввода-вывода (чтение и запись) с диска в секунду
|
||||
@{name="ReadsIOps";expression={$_.DiskReadsPersec}}, # Количество операций чтения с диска в секунду
|
||||
@{name="WriteIOps";expression={$_.DiskWritesPersec}} # Количество операций записи на диск в секунду
|
||||
}
|
||||
|
|
@ -2,16 +2,31 @@ function Get-MemorySize {
|
|||
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
|
||||
$PageSize = $Memory.TotalVirtualMemorySize - $Memory.TotalVisibleMemorySize
|
||||
$PageFree = $Memory.FreeVirtualMemory - $Memory.FreePhysicalMemory
|
||||
$PageUse = $PageSize - $PageFree
|
||||
$PageUseProc = ($PageUse / $PageSize) * 100
|
||||
$PageFile = Get-CimInstance Win32_PageFileUsage
|
||||
$PagePath = [string]$($PageFile).Description
|
||||
$MemVirtUse = $Memory.TotalVirtualMemorySize - $Memory.FreeVirtualMemory
|
||||
$MemVirtUseProc = ($MemVirtUse / $Memory.TotalVirtualMemorySize) * 100
|
||||
$GetProcess = Get-Process
|
||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$pm = ((($GetProcess).PM | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||
$CollectionMemory = New-Object System.Collections.Generic.List[System.Object]
|
||||
$CollectionMemory.Add([PSCustomObject]@{
|
||||
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
|
||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||
WorkingSet = $ws
|
||||
PageMemory = $pm
|
||||
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
|
||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||
PageSize = ($PageSize/1mb).ToString("0.00 GB")
|
||||
PageUse = ($PageUse/1mb).ToString("0.00 GB")
|
||||
PageUseProc = [string]([int]$PageUseProc)+" %"
|
||||
PagePath = $PagePath
|
||||
MemoryVirtAll = ($memory.TotalVirtualMemorySize/1mb).ToString("0.00 GB")
|
||||
MemoryVirtUse = ($MemVirtUse/1mb).ToString("0.00 GB")
|
||||
MemoryVirtUseProc = [string]([int]$MemVirtUseProc)+" %"
|
||||
ProcWorkingSet = $ws
|
||||
ProcPageMemory = $pm
|
||||
})
|
||||
$CollectionMemory
|
||||
}
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
function Get-MemorySlots {
|
||||
$Memory = Get-CimInstance Win32_PhysicalMemory | Select-Object Manufacturer,PartNumber,
|
||||
ConfiguredClockSpeed,@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}},
|
||||
Tag,DeviceLocator,BankLabel
|
||||
$Memory = Get-CimInstance Win32_PhysicalMemory |
|
||||
Select-Object Manufacturer,
|
||||
PartNumber,
|
||||
ConfiguredClockSpeed,
|
||||
@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}},
|
||||
Tag,DeviceLocator,
|
||||
BankLabel
|
||||
$CollectionMemory = New-Object System.Collections.Generic.List[System.Object]
|
||||
$Memory | ForEach-Object {
|
||||
$CollectionMemory.Add([PSCustomObject]@{
|
||||
|
|
|
|||
40
Scripts/Get-NetInterfaceStat.psm1
Normal file
40
Scripts/Get-NetInterfaceStat.psm1
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
function Get-NetInterfaceStat {
|
||||
param (
|
||||
[switch]$Current
|
||||
)
|
||||
if ($Current) {
|
||||
Get-CimInstance -ClassName Win32_PerfFormattedData_Tcpip_NetworkInterface |
|
||||
Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1mb).ToString("0.000 MByte/Sec")}}, # Сумма полученных и отправленных байт за секунду
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1mb).ToString("0.000 MByte/Sec")}}, # Количество байт, полученных за секунду
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1mb).ToString("0.000 MByte/Sec")}}, # Количество байт, отправленных за секунду
|
||||
PacketsPersec, # Общее количество пакетов в секунду (включает все виды пакетов)
|
||||
PacketsReceivedPersec, # Количество пакетов, полученных за секунду
|
||||
PacketsReceivedUnicastPersec, # Количество уникальных (unicast) пакетов, полученных за секунду, включает в себя широковещательные (broadcast) и групповые (multicast) пакеты
|
||||
PacketsReceivedNonUnicastPersec, # Количество не уникальных (non-unicast) пакетов, полученных за секунду
|
||||
PacketsReceivedDiscarded, # Количество отброшенных пакетов при получении
|
||||
PacketsReceivedErrors, # Количество пакетов с ошибками при получении
|
||||
PacketsSentPersec, # Количество пакетов, отправленных за секунду
|
||||
PacketsSentUnicastPersec, # Количество уникальных (unicast) пакетов, отправленных за секунду
|
||||
PacketsSentNonUnicastPersec # Количество не уникальных (non-unicast) пакетов, отправленных за секунду
|
||||
}
|
||||
else {
|
||||
Get-CimInstance -ClassName Win32_PerfRawData_Tcpip_NetworkInterface |
|
||||
Select-Object Name,
|
||||
@{name="Total";expression={$($_.BytesTotalPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Received";expression={$($_.BytesReceivedPersec/1gb).ToString("0.00 GByte")}},
|
||||
@{name="Sent";expression={$($_.BytesSentPersec/1gb).ToString("0.00 GByte")}},
|
||||
PacketsPersec,
|
||||
PacketsReceivedPersec,
|
||||
PacketsReceivedUnicastPersec,
|
||||
PacketsReceivedNonUnicastPersec,
|
||||
PacketsReceivedDiscarded,
|
||||
PacketsReceivedErrors,
|
||||
PacketsSentPersec,
|
||||
PacketsSentUnicastPersec,
|
||||
PacketsSentNonUnicastPersec
|
||||
}
|
||||
}
|
||||
|
||||
# Get-NetInterfaceStat -Current
|
||||
# Get-NetInterfaceStat
|
||||
13
Scripts/Get-NetIpConfig.psm1
Normal file
13
Scripts/Get-NetIpConfig.psm1
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
function Get-NetIpConfig {
|
||||
Get-CimInstance -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=$true |
|
||||
Select-Object Description,
|
||||
@{Label="IPAddress"; Expression={[string]($_.IPAddress)}},
|
||||
@{Label="GatewayDefault"; Expression={[string]($_.DefaultIPGateway)}},
|
||||
@{Label="Subnet"; Expression={[string]($_.IPSubnet)}},
|
||||
@{Label="DNSServer"; Expression={[string]($_.DNSServerSearchOrder)}},
|
||||
MACAddress,
|
||||
DHCPEnabled,
|
||||
DHCPServer,
|
||||
DHCPLeaseObtained,
|
||||
DHCPLeaseExpires
|
||||
}
|
||||
|
|
@ -1,30 +1,13 @@
|
|||
function Get-Netstat {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Remote and local view network tcp connections statistics and his used process
|
||||
Using Get-NetTCPConnection, ps, nslookup and Invoke-Command via WinRM
|
||||
.DESCRIPTION
|
||||
Example:
|
||||
Get-Netstat localhost # default
|
||||
Get-Netstat server-01 # remote host
|
||||
.LINK
|
||||
https://github.com/Lifailon
|
||||
#>
|
||||
Param (
|
||||
$srv="localhost"
|
||||
)
|
||||
if ($srv -like "localhost") {
|
||||
Get-NetTCPConnection -State Established,Listen | sort -Descending State | select CreationTime,LocalAddress,LocalPort,RemotePort,
|
||||
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},RemoteAddress,
|
||||
State,@{name="ProcessName";expression={(ps -Id $_.OwningProcess).ProcessName}},
|
||||
@{name="ProcessPath";expression={(ps -Id $_.OwningProcess).Path}} | Out-GridView -Title "Local netstat"
|
||||
}
|
||||
else {
|
||||
icm $srv {Get-NetTCPConnection -State Established,Listen | sort -Descending State | select CreationTime,LocalAddress,LocalPort,
|
||||
RemotePort,RemoteAddress,
|
||||
State,@{name="ProcessName";expression={(ps -Id $_.OwningProcess).ProcessName}},
|
||||
@{name="ProcessPath";expression={(ps -Id $_.OwningProcess).Path}}} | select CreationTime,LocalAddress,LocalPort,RemotePort,
|
||||
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},
|
||||
RemoteAddress,State,ProcessName,ProcessPath | Out-GridView -Title "Remote netstat to server: $srv"
|
||||
}
|
||||
function Get-NetStat {
|
||||
Get-NetTCPConnection -State Established,Listen | Sort-Object -Descending State |
|
||||
Select-Object @{name="ProcessName";expression={(Get-Process -Id $_.OwningProcess).ProcessName}},
|
||||
LocalAddress,
|
||||
LocalPort,
|
||||
RemotePort,
|
||||
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},
|
||||
RemoteAddress,
|
||||
State,
|
||||
CreationTime,
|
||||
@{Name="RunTime"; Expression={((Get-Date) - $_.CreationTime) -replace "\.\d+$"}},
|
||||
@{name="ProcessPath";expression={(Get-Process -Id $_.OwningProcess).Path}}
|
||||
}
|
||||
30
Scripts/Get-NetstatRemote.psm1
Normal file
30
Scripts/Get-NetstatRemote.psm1
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
function Get-Netstat {
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Remote and local view network tcp connections statistics and his used process
|
||||
Using Get-NetTCPConnection, ps, nslookup and Invoke-Command via WinRM
|
||||
.DESCRIPTION
|
||||
Example:
|
||||
Get-Netstat localhost # default
|
||||
Get-Netstat server-01 # remote host
|
||||
.LINK
|
||||
https://github.com/Lifailon
|
||||
#>
|
||||
Param (
|
||||
$srv="localhost"
|
||||
)
|
||||
if ($srv -like "localhost") {
|
||||
Get-NetTCPConnection -State Established,Listen | sort -Descending State | select CreationTime,LocalAddress,LocalPort,RemotePort,
|
||||
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},RemoteAddress,
|
||||
State,@{name="ProcessName";expression={(ps -Id $_.OwningProcess).ProcessName}},
|
||||
@{name="ProcessPath";expression={(ps -Id $_.OwningProcess).Path}} | Out-GridView -Title "Local netstat"
|
||||
}
|
||||
else {
|
||||
icm $srv {Get-NetTCPConnection -State Established,Listen | sort -Descending State | select CreationTime,LocalAddress,LocalPort,
|
||||
RemotePort,RemoteAddress,
|
||||
State,@{name="ProcessName";expression={(ps -Id $_.OwningProcess).ProcessName}},
|
||||
@{name="ProcessPath";expression={(ps -Id $_.OwningProcess).Path}}} | select CreationTime,LocalAddress,LocalPort,RemotePort,
|
||||
@{name="RemoteHostName";expression={((nslookup $_.RemoteAddress)[3]) -replace ".+:\s+"}},
|
||||
RemoteAddress,State,ProcessName,ProcessPath | Out-GridView -Title "Remote netstat to server: $srv"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
function Get-PD {
|
||||
$PhysicalDisk = Get-CimInstance Win32_DiskDrive | Select-Object Model,
|
||||
@{Label="Size"; Expression={[int]($_.Size/1Gb)}},Partitions,InterfaceType
|
||||
$CollectionPD = New-Object System.Collections.Generic.List[System.Object]
|
||||
$PhysicalDisk | ForEach-Object {
|
||||
$CollectionPD.Add([PSCustomObject]@{
|
||||
Model = $_.Model
|
||||
Size = [string]$_.Size+" Gb"
|
||||
PartitionCount = $_.Partitions
|
||||
Interface = $_.InterfaceType
|
||||
})
|
||||
}
|
||||
$CollectionPD
|
||||
}
|
||||
22
Scripts/Get-Smart.psm1
Normal file
22
Scripts/Get-Smart.psm1
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
function Get-Smart {
|
||||
$PhysicalDisk = Get-CimInstance -Namespace root/Microsoft/Windows/Storage -ClassName MSFT_PhysicalDisk
|
||||
$DiskSensor = $PhysicalDisk | Get-StorageReliabilityCounter
|
||||
$DiskSensor | Select-Object @{Label="DiskName"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DeviceId | Select-Object -ExpandProperty FriendlyName}},
|
||||
Temperature,
|
||||
@{Label="HealthStatus"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DeviceId | Select-Object -ExpandProperty HealthStatus}},
|
||||
@{Label="OperationalStatus"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DeviceId | Select-Object -ExpandProperty OperationalStatus}},
|
||||
@{Label="MediaType"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DeviceId | Select-Object -ExpandProperty MediaType}},
|
||||
@{Label="BusType"; Expression={$PhysicalDisk | Where-Object DeviceId -eq $_.DeviceId | Select-Object -ExpandProperty BusType}},
|
||||
PowerOnHours, # Количество часов, в течение которых жесткий диск был во включенном состоянии
|
||||
StartStopCycleCount, # Количество циклов включения и выключения жесткого диска (каждый цикл выключения и последующего включения считается за один раз)
|
||||
FlushLatencyMax, # Максимальное время задержки (латентность) для операций очистки кэша на диске (сброса кеша на диск).
|
||||
LoadUnloadCycleCount, # Количество циклов загрузки/выгрузки механизма парковки головок на жёстких дисках с перемещающимися головками (не относится к SSD)
|
||||
ReadErrorsTotal, # Общее количество ошибок чтения данных с диска
|
||||
ReadErrorsCorrected, # Количество ошибок чтения, которые были исправлены системой коррекции ошибок
|
||||
ReadErrorsUncorrected, # Количество ошибок чтения, которые не удалось исправить
|
||||
ReadLatencyMax, # Максимальная задержка (латентность) при чтении данных с диска
|
||||
WriteErrorsTotal,
|
||||
WriteErrorsCorrected,
|
||||
WriteErrorsUncorrected,
|
||||
WriteLatencyMax
|
||||
}
|
||||
8
Scripts/Get-Software.psm1
Normal file
8
Scripts/Get-Software.psm1
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
function Get-Software {
|
||||
Get-CimInstance Win32_Product | Select-Object Name,
|
||||
Version,
|
||||
Vendor,
|
||||
InstallDate,
|
||||
InstallLocation,
|
||||
InstallSource
|
||||
}
|
||||
11
Scripts/Get-Temperature.psm1
Normal file
11
Scripts/Get-Temperature.psm1
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Get-CimInstance CIM_TemperatureSensor
|
||||
# Get-CimInstance Win32_TemperatureProbe
|
||||
# Get-CimInstance Win32_PerfFormattedData_Counters_ThermalZoneInformation
|
||||
# Get-CimInstance MSAcpi_ThermalZoneTemperature -Namespace root/WMI
|
||||
# Get-CimInstance CIM_Fan
|
||||
# Get-CimInstance CIM_CoolingDevice
|
||||
|
||||
function Get-Temperature {
|
||||
$ThermalZoneTemperature = Get-CimInstance MSAcpi_ThermalZoneTemperature -Namespace root/WMI
|
||||
$ThermalZoneTemperature.CurrentTemperature / 10 - 273.15
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ function Get-VideoCard {
|
|||
$CollectionVC.Add([PSCustomObject]@{
|
||||
Model = $_.VideoCard
|
||||
Display = $_.Display
|
||||
VideoRAM = [string]$_.vRAM+" Gb"
|
||||
VideoRAM = [string]$([int]$($_.vRAM))+" Gb"
|
||||
})
|
||||
}
|
||||
$CollectionVC
|
||||
|
|
|
|||
9
Scripts/Get-WinUpdate.psm1
Normal file
9
Scripts/Get-WinUpdate.psm1
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
function Get-WinUpdate {
|
||||
Get-CimInstance Win32_QuickFixEngineering | Select-Object HotFixID,
|
||||
Description,
|
||||
InstalledBy,
|
||||
InstalledOn
|
||||
# wusa /uninstall /kb:123456
|
||||
# dism /Online /Get-Packages /format:table
|
||||
# dism /Online /Remove-Package /PackageName:Package_for_DotNetRollup_481~31bf3856ad364e35~amd64~~10.0.9206.1 /quiet /norestart
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue