Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

How can i use Get-Focus or Get-Window in powershell 2.0

$
0
0

Dear All,

Hope you all are fine.

This is my first post on Powershell.com

 

Question:>>  How can I use Get-Focus or Get-Window in powershell 2.0.

I am trying to get the total uptime of a process during a day using

Example:(get-date).Subtract((Get-Process firefox).starttime)|findstr 'TotalHours'

Now the concern is this is not the efficient time as the user can open the process window and minimize it for full day.

**** So I am looking for the cmdlet that will only capture the duration when the Process/Window has focus or is active. This way we will have the actual duration the user was working on that process.

Dear Experts, kindly guide me

Limitation - I cannot upgrade Powershell version, so need a fix with powershell 2.0 onlySad

I am using powershell 2.0 and there is No cmdlet available to match my requirement of above cmdlet

I have already checked all available in 2.0

http://technet.microsoft.com/en-us/magazine/ff714569.aspx

PS C:\Users> get-host


Name             : ConsoleHost
Version          : 2.0
InstanceId       : 2aec344a-619b-4455-b086-42ba5ca60995
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.ConsoleHost+ConsoleColorProxy
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace



PS C:\Users> $PSVersionTable

Name                           Value
----                           -----
CLRVersion                     2.0.50727.5477
BuildVersion                   6.1.7601.17514
PSVersion                      2.0
WSManStackVersion              2.0
PSCompatibleVersions           {1.0, 2.0}
SerializationVersion           1.1.0.1
PSRemotingProtocolVersion      2.1

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles