Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [hashtable]$processes = @{}
- [hashtable]$processParameters = @{}
- if( (Get-Command -Name get-process).Parameters.ContainsKey( 'IncludeUsername' ) )
- {
- $myWindowsPrincipal = New-Object -TypeName System.Security.Principal.WindowsPrincipal([System.Security.Principal.WindowsIdentity]::GetCurrent())
- if ( $myWindowsPrincipal -and $myWindowsPrincipal.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator ))
- {
- $processParameters.Add( 'IncludeUsername' , $true )
- }
- }
- ## Create hashtable of processes keyed on id so we can do a fast lookup via pid
- Get-Process @processParameters | ForEach-Object `
- {
- $processes.Add( [uint32]$_.Id , $_ )
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement