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

Capture Logon & Logout time

$
0
0

Hi Team,

 

I am looking script which will capture my In-Time & Out-Time when I am in office. It should not capture time when I Turn On my laptop at home.

Below procedure I follow when I am come to office.

 

1)     I switch on the laptop as soon as I come to office.

2)     Then I plug network cable.

3)     I login to the domain.

Sometime I used to plug the network cable after I login to the system.

 

By considering this fact I created below PS scrip which run in to logon. This script runs fine when I plug the network cable before I login to the system however its capture time twice if I plug the cable after I login to the system.

do{$pingy = Get-WmiObject Win32_PingStatus -f "Address='<DC server Name>’"}until($pingy.StatusCode -eq 0);Get-Date  | Export-Csv -NoTypeInformation -Append -Path c:\OfficeTime\Time.csv

 

if my requirement can accomplish other than the above script I am ok.

 

 

Please note that I do not have domain admin rights however I do have admin rights in local system.


Viewing all articles
Browse latest Browse all 6937

Trending Articles