Skip to content

Commit

Permalink
Improvements
Browse files Browse the repository at this point in the history
1. Added webappname to log name
2. Moved day of week last
3. Removed miliseconds
4. Added UTC
5. Amended search to look for old and new names.
  • Loading branch information
ProfiseeAdmin committed Jun 10, 2024
1 parent 5c71779 commit b9ac9c9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions Azure-ARM/forensics_log_pull.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Pull Product Services, IIS, Event Viewer logs as well as Netstat and TCPConnection logs
$DT = get-date -Format "ddd-MM-dd-yy-HHmmss-ffff-Z"
# Pull Product Services, IIS, Event Viewer logs as well as Netstat and TCPConnection logs
$DT = get-date -UFormat "%m-%d-%Y-%H%M%S-UTC-%a"
mkdir "$env:TEMP\all-Logs\$DT\ProfiseeLogs\Config"
mkdir "$env:TEMP\all-Logs\$DT\ProfiseeLogs\Gateway"
mkdir "$env:TEMP\all-Logs\$DT\ProfiseeLogs\Attachments"
Expand All @@ -26,9 +26,12 @@ robocopy "c:\inetpub\logs\LogFiles\W3SVC1" "$env:TEMP\all-Logs\$DT\IISLogs" /E /
netstat -anobq > $env:TEMP\all-Logs\$DT\TCPLogs\netstat.txt
Get-NetTCPConnection | Group-Object -Property State, OwningProcess | Select -Property Count, Name, @{Name="ProcessName";Expression={(Get-Process -PID ($_.Name.Split(',')[-1].Trim(' '))).Name}}, Group | Sort Count -Descending | out-file $env:TEMP\all-Logs\$DT\TCPLogs\TCPconnections.txt

#Compress and copy to fileshare
compress-archive -Path "$env:TEMP\all-Logs\$DT\" -DestinationPath "$env:TEMP\all-Logs-$DT.zip"
copy "$env:TEMP\all-Logs-$DT.zip" "C:\fileshare\"
# Make Webapp name w/ Capital letter
$WebAppName = $env:ProfiseeWebAppName.substring(0, 1).ToUpper() + $env:ProfiseeWebAppName.Substring(1)

#delete older zipped log files more than 30 days
Get-ChildItem -Path C:\Fileshare\* -Include all-logs-*.zip -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item
# Compress and copy to fileshare
compress-archive -Path "$env:TEMP\all-Logs\$DT\" -DestinationPath "$env:TEMP\$WebAppName-All-Logs-$DT.zip"
copy "$env:TEMP\$WebAppName-All-Logs-$DT.zip" "C:\fileshare\"

# Delete older zipped log files more than 30 days
Get-ChildItem -Path C:\Fileshare\* -Include *all-logs-*.zip -Recurse | Where-Object {$_.LastWriteTime -lt (Get-Date).AddDays(-30)} | Remove-Item

0 comments on commit b9ac9c9

Please sign in to comment.