Skip to content

Commit

Permalink
Create logonsessions.ps1
Browse files Browse the repository at this point in the history
  • Loading branch information
SOCFortress authored Aug 9, 2022
1 parent 5145ce2 commit 9360cb7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions Windows Logon Sessions/logonsessions.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
################################
##########
# Script execution triggered by Wazuh Manager, wodles-command
# Output converted to JSON and appended to active-responses.log
##########
# RUN LOGONSESSIONS AND STORE CSV
$Sessions_Output_CSV = c:\"Program Files"\Sysinternals\logonsessions.exe -nobanner -c -p
# REMOVE SPACES IN CSV HEADER AND CONVERT TO ARRAY
$Sessions_Output_Array = $Sessions_Output_CSV.PSObject.BaseObject.Trim(' ') -Replace '\s','' | ConvertFrom-Csv
# GO THRU THE ARRAY, CONVERT TO JSON AND APPEND TO active-responses.log
Foreach ($item in $Sessions_Output_Array) {
echo $item | ConvertTo-Json -Compress | Out-File -width 2000 C:\"Program Files (x86)"\ossec-agent\active-response\active-responses.log -Append -Encoding ascii
}

0 comments on commit 9360cb7

Please sign in to comment.