ProcessInfo.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function Write-Color-Process
{
    param ([string]$color = "white", $file)

    Write-host ("{0,-7} {1,25} {2,10} {3}" -f $file.mode, ([String]::Format("{0,10} {1,8}", $file.LastWriteTime.ToString("d"), $file.LastWriteTime.ToString("t"))), (Write-FileLength $file.length), $file.name) -foregroundcolor $color
}

function ProcessInfo {
        param (
        [Parameter(Mandatory=$True,Position=1)]
        $process
    )

    if($script:showHeader)
    {
        Write-Host        
        Write-Host 'Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName'
        Write-Host '------- ------ ----- ----- ----- ------ -- -----------'
        $script:showHeader=$false
    }
    $id = $_.Id
    $owner = (Get-WmiObject -Class Win32_Process -Filter "ProcessId = $id").getowner()

    Write-Host ("{0,7} {1,7} {2,8} {3} {4}" -f $_.Handles, `
        [math]::Round($_.NonpagedSystemMemorySize / 1KB), `
        [math]::Round($_.PagedMemorySize / 1KB),
        $owner.domain,
        $owner.user

        )
}