Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get lastlogontimestamp in a readable format with a batch file

$
0
0

I have a batch file I run on active directory.  It tells me the last time all computers were logged on but I have to do some conversions after it runs.  I found a way to make the batch file better but I am having trouble making it do what I want as I have a poor understanding of tokens and delims.

 

My simple batch file produces a long csv file called results below is a small piece of the file.

 

It pulls dn,cn,description,lastLogonTimestamp  There may or may not be a description

 

"CN=computername1,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com",computer1,remoteoffice.FrontCounter,129082143618551380

"CN= computername2,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer2,remoteoffice.HR.someuser,129083939351940914

"CN= computername3,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer3,remoteoffice.FrontCounter,129085716471724228

"CN= computername4,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer4,,129088288899474132

"CN= computername5,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer5,remoteoffice.Marketing.someuser,129083902992666669

"CN= computername6,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer6,remoteoffice.WFX.someuser,129082988450522254

"CN= computername7,OU=computers,OU=marketing,OU=EAST,DC=CORP,DC=SOMEDOMAIN,DC=com", computer7,remoteoffice.Warehouse.someuser,129088938237899108

The very last section which is the time stamp I want to replace that value with a readable date format by using  w32tm.exe /ntte .

So for line one run w32tm.exe /ntte 129082143618551380 and replace 129082143618551380 with the output and so forth

If it has to produce another csv file that is no problem.

 

Thanks so much in advance


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>