Advertisement
actuallykane

Upload windows event logs to pastebin

Nov 27th, 2018
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $now=get-date
  2. $startdate=$now.adddays(-1)
  3.  
  4. $el = get-eventlog -log System -After $startdate -EntryType Error, Warning, Information
  5.  
  6. $filename = $el[0].MachineName.Replace(".ad.kanersps.pw", "") + "_" + (Get-Date -UFormat "%d-%m-%Y_%H-%M")
  7.  
  8. $Body = @{
  9.     api_dev_key = 'devkey'
  10.     api_user_name = 'username'
  11.     api_user_password = 'userpassword'
  12. }
  13.  
  14. $LoginKey = (Invoke-WebRequest -Uri "https://pastebin.com/api/api_login.php" -UseBasicParsing -Body $Body -Method Post).Content
  15.  
  16. $Content = @"
  17. | Index | TimeGenerated | EntryType | Source | InstanceID | Message |
  18. |-------|------|-----------|--------|------------|---------|
  19. "@
  20.  
  21. ForEach($event in $el){
  22.     $Content += "`n| " + $event.Index + " | " + $event.TimeGenerated + " | " + $event.EntryType + " | " + $event.Source + " | " + $event.InstanceId + " | " + $event.Message.replace("`n",", ").replace("`r",", ") + " |"
  23. }
  24.  
  25. $Body = @{
  26.     api_dev_key = 'devkey'
  27.     api_paste_code = ($Content)
  28.     api_paste_private = 2
  29.     api_paste_name = $filename
  30.     api_option = 'paste'
  31.     api_user_key = $LoginKey
  32.     api_paste_format = "markdown"
  33. }
  34.  
  35. Invoke-WebRequest -Uri "https://pastebin.com/api/api_post.php" -UseBasicParsing -Body $Body -Method Post
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement