Add modules from WinAPI
This commit is contained in:
parent
1b6125edfa
commit
b884c8e545
1 changed files with 15 additions and 7 deletions
|
|
@ -6,19 +6,24 @@ function Get-Files {
|
|||
$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"
|
||||
$type = "Directory"
|
||||
$ChildItem = Get-ChildItem -Path $file.FullName -Recurse -ErrorAction Ignore
|
||||
$size = ($ChildItem | Measure-Object -Property Length -Sum).Sum/1gb
|
||||
$size = [string]([double]::Round($size, 3))+" GB"
|
||||
$Files_Count = $ChildItem | Where-Object { $_.PSIsContainer -eq $false }
|
||||
$Directory_Count = $ChildItem | Where-Object { $_.PSIsContainer -eq $true }
|
||||
} else {
|
||||
$type = "File"
|
||||
$size = $file.Length / 1gb
|
||||
$size = [string]([double]::Round($size, 3))+" GB"
|
||||
$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
|
||||
Files = $Files_Count.Count
|
||||
Directory = $Directory_Count.Count
|
||||
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"
|
||||
|
|
@ -26,5 +31,8 @@ function Get-Files {
|
|||
}
|
||||
$Collection_Files
|
||||
}
|
||||
|
||||
# Get-Files -Path "C:/"
|
||||
# Get-Files -Path "C:/Program Files/"
|
||||
# Get-Files -Path "D:/"
|
||||
# Get-Files -Path "D:/Movies/"
|
||||
Loading…
Add table
Add a link
Reference in a new issue