Add modules from WinAPI
This commit is contained in:
parent
bbfdb5d61f
commit
27a1568d53
5 changed files with 54 additions and 9 deletions
9
Scripts/Get-CPUse.psm1
Normal file
9
Scripts/Get-CPUse.psm1
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
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
|
||||||
|
}
|
||||||
30
Scripts/Get-Files.psm1
Normal file
30
Scripts/Get-Files.psm1
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
function Get-Files {
|
||||||
|
param (
|
||||||
|
[Parameter(Mandatory)][string]$Path
|
||||||
|
)
|
||||||
|
$files = Get-ChildItem $Path
|
||||||
|
$Collection_Files = New-Object System.Collections.Generic.List[System.Object]
|
||||||
|
foreach ($file in $files) {
|
||||||
|
if ($file.Length -eq 1) {
|
||||||
|
$type = "Directory"
|
||||||
|
$size = (Get-ChildItem -Path $file.FullName -Recurse -ErrorAction Ignore | Measure-Object -Property Length -Sum).Sum/1gb
|
||||||
|
$size = [string]([double]::Round($size, 3))+" GB"
|
||||||
|
} else {
|
||||||
|
$type = "File"
|
||||||
|
$size = $file.Length / 1gb
|
||||||
|
$size = [string]([double]::Round($size, 3))+" GB"
|
||||||
|
}
|
||||||
|
$Collection_Files.Add([PSCustomObject]@{
|
||||||
|
Name = $file.Name
|
||||||
|
FullName = $file.FullName
|
||||||
|
Type = $type
|
||||||
|
Size = $size
|
||||||
|
CreationTime = Get-Date -Date $file.CreationTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||||
|
LastAccessTime = Get-Date -Date $file.LastAccessTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||||
|
LastWriteTime = Get-Date -Date $file.LastWriteTime -Format "dd/MM/yyyy hh:mm:ss"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
$Collection_Files
|
||||||
|
}
|
||||||
|
# Get-Files -Path "C:/"
|
||||||
|
# Get-Files -Path "C:/Program Files/"
|
||||||
|
|
@ -25,7 +25,8 @@ function Get-Hardware {
|
||||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||||
$pm = ((($GetProcess).PM | 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
|
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||||
|
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
|
||||||
$MEM = Get-CimInstance Win32_PhysicalMemory | Select-Object Manufacturer,PartNumber,
|
$MEM = Get-CimInstance Win32_PhysicalMemory | Select-Object Manufacturer,PartNumber,
|
||||||
ConfiguredClockSpeed,@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
ConfiguredClockSpeed,@{Label="Memory"; Expression={[string]($_.Capacity/1Mb)}}
|
||||||
$MEMs = $MEM.Memory | Measure-Object -Sum
|
$MEMs = $MEM.Memory | Measure-Object -Sum
|
||||||
|
|
@ -65,6 +66,7 @@ function Get-Hardware {
|
||||||
HandlesCount = $Handles_Count
|
HandlesCount = $Handles_Count
|
||||||
MemoryAll = [string]$($MEMs.Sum/1Kb)+" GB"
|
MemoryAll = [string]$($MEMs.Sum/1Kb)+" GB"
|
||||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||||
|
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||||
WorkingSet = $ws
|
WorkingSet = $ws
|
||||||
PageMemory = $pm
|
PageMemory = $pm
|
||||||
MemorySlots = $MEMs.Count
|
MemorySlots = $MEMs.Count
|
||||||
|
|
|
||||||
|
|
@ -3,14 +3,16 @@ function Get-LD {
|
||||||
Label="Value"; Expression={$_.DeviceID}}, @{Label="AllSize"; Expression={
|
Label="Value"; Expression={$_.DeviceID}}, @{Label="AllSize"; Expression={
|
||||||
([int]($_.Size/1Gb))}},@{Label="FreeSize"; Expression={
|
([int]($_.Size/1Gb))}},@{Label="FreeSize"; Expression={
|
||||||
([int]($_.FreeSpace/1Gb))}}, @{Label="Free%"; Expression={
|
([int]($_.FreeSpace/1Gb))}}, @{Label="Free%"; Expression={
|
||||||
[string]([int]($_.FreeSpace/$_.Size*100))+" %"}}
|
[string]([int]($_.FreeSpace/$_.Size*100))+" %"}},FileSystem,VolumeName
|
||||||
$CollectionLD = New-Object System.Collections.Generic.List[System.Object]
|
$CollectionLD = New-Object System.Collections.Generic.List[System.Object]
|
||||||
$LogicalDisk | ForEach-Object {
|
$LogicalDisk | ForEach-Object {
|
||||||
$CollectionLD.Add([PSCustomObject]@{
|
$CollectionLD.Add([PSCustomObject]@{
|
||||||
Logical_Disk = $_.Value
|
Logical_Disk = $_.Value
|
||||||
AllSize = [string]$_.AllSize+" Gb"
|
FileSystem = $_.FileSystem
|
||||||
FreeSize = [string]$_.FreeSize+" Gb"
|
VolumeName = $_.VolumeName
|
||||||
Free = $_."Free%"
|
AllSize = [string]$_.AllSize+" Gb"
|
||||||
|
FreeSize = [string]$_.FreeSize+" Gb"
|
||||||
|
Free = $_."Free%"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
$CollectionLD
|
$CollectionLD
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,17 @@
|
||||||
function Get-MemorySize {
|
function Get-MemorySize {
|
||||||
$Memory = Get-CimInstance Win32_OperatingSystem
|
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||||
|
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 100
|
||||||
$GetProcess = Get-Process
|
$GetProcess = Get-Process
|
||||||
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
$ws = ((($GetProcess).WorkingSet | Measure-Object -Sum).Sum/1gb).ToString("0.00 GB")
|
||||||
$pm = ((($GetProcess).PM | 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 = New-Object System.Collections.Generic.List[System.Object]
|
||||||
$CollectionMemory.Add([PSCustomObject]@{
|
$CollectionMemory.Add([PSCustomObject]@{
|
||||||
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
|
MemoryAll = ($memory.TotalVisibleMemorySize/1mb).ToString("0.00 GB")
|
||||||
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
MemoryUse = ($MemUse/1mb).ToString("0.00 GB")
|
||||||
WorkingSet = $ws
|
MemoryUseProc = [string]([int]$MemUserProc)+" %"
|
||||||
PageMemory = $pm
|
WorkingSet = $ws
|
||||||
|
PageMemory = $pm
|
||||||
})
|
})
|
||||||
$CollectionMemory
|
$CollectionMemory
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue