I would like to track when users log off their workstations. I have created this script but it doesn't seem to be working. Do I first need a command to create the log file if it doesn't exist? I tried creating a log file manaully and that didn't work either.

$logfile = "\\servername\userlogs$\@USERID.log"
$logfile = WRITELINE("LOGOFF ;"+@DATE+";"+@TIME+";"+@USERID+";"+@WKSTA+@CRLF)