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/"
|
||||
|
|
@ -26,6 +26,7 @@ function Get-Hardware {
|
|||
$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
|
||||
|
|
@ -65,6 +66,7 @@ function Get-Hardware {
|
|||
HandlesCount = $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
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ function Get-LD {
|
|||
Label="Value"; Expression={$_.DeviceID}}, @{Label="AllSize"; Expression={
|
||||
([int]($_.Size/1Gb))}},@{Label="FreeSize"; 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]
|
||||
$LogicalDisk | ForEach-Object {
|
||||
$CollectionLD.Add([PSCustomObject]@{
|
||||
Logical_Disk = $_.Value
|
||||
FileSystem = $_.FileSystem
|
||||
VolumeName = $_.VolumeName
|
||||
AllSize = [string]$_.AllSize+" Gb"
|
||||
FreeSize = [string]$_.FreeSize+" Gb"
|
||||
Free = $_."Free%"
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
function Get-MemorySize {
|
||||
$Memory = Get-CimInstance Win32_OperatingSystem
|
||||
$MemUse = $Memory.TotalVisibleMemorySize - $Memory.FreePhysicalMemory
|
||||
$MemUserProc = ($MemUse / $Memory.TotalVisibleMemorySize) * 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")
|
||||
|
|
@ -8,6 +9,7 @@ function Get-MemorySize {
|
|||
$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
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue