Created
March 19, 2015 16:23
-
-
Save XPlantefeve/f91e144b7200338a7122 to your computer and use it in GitHub Desktop.
logon index / find a computer's main user
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ComputerName = $env:ComputerName | |
| $test = Import-Csv -Path "log:\computers\${ComputerName}.log" -Delimiter ' ' -header @('user','date','time') | |
| $t2 = $test | | |
| select user,date,@{ | |
| name='logonage'; | |
| expression={ | |
| 1 / ((Get-Date) - [DateTime]$_.date).Days} | |
| } | | |
| group user | | |
| select Count,Name,@{ | |
| Name='index'; | |
| Expression={ | |
| "{0:N2}" -f (($_.Group | measure -Property logonage -Average).Average * $_.count * 10) | |
| } | |
| } | |
| $t2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment