Hi,
I am working on a logging script for some servers, the data im looking to pull is all users logged on, date, count. i want to run this for about 3 days and pull data about 5 mins apart.
I am outputting to a csv file, but when it outputs its overwriting my previous data. I tried noclobber but that just errors out and says file already exists
$date = Get-Date -format g
$server = "ctx45dcepc62"
$file = ".\users.csv"
Import-Module psterminalservices
$users = get-tssession -computername $server -Filter {$_.username -AND $_.ConnectionState -eq 'Active'} | select username
$count = $users.Count
$users | add-member -name Date -type noteproperty $date
$users | add-member -name Count -type noteproperty $count
$users | export-csv $file -NoTypeInformation
Could some one help me out, or should i not use export-csv? Also how would i get a 5 min timer to run this script say for 3 days?
Thanks in advance