I'm new in powershell and I'd like to create a script to:
1. read the time of the last transaction log in a sql file. This file may contain many transactions log that have been loaded:
Ex: LOAD TRAN PS1 FROM 'C:\PS1.TRAN.20141029.085631.000'
2. make a difference between that time and the current time and write the result to a text file
So, PowerShell doesn't natively have a means of reading SQL Server t-log files. You can use the SQL module's Invoke-SQL command to execute your LOAD TRAN statement, though. Basically, whatever you'd do in a Query Window in SSMS.
You'll need to parse that date into a DateTime object – again, it might be a lot easier just to use T-SQL for that, since T-SQL already understands that format and has a DATEDIFF() function to do date differences.