Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $now=get-date
- $startdate=$now.adddays(-1)
- $el = get-eventlog -log System -After $startdate -EntryType Error, Warning, Information
- $filename = $el[0].MachineName.Replace(".ad.kanersps.pw", "") + "_" + (Get-Date -UFormat "%d-%m-%Y_%H-%M")
- $Body = @{
- api_dev_key = 'devkey'
- api_user_name = 'username'
- api_user_password = 'userpassword'
- }
- $LoginKey = (Invoke-WebRequest -Uri "https://pastebin.com/api/api_login.php" -UseBasicParsing -Body $Body -Method Post).Content
- $Content = @"
- | Index | TimeGenerated | EntryType | Source | InstanceID | Message |
- |-------|------|-----------|--------|------------|---------|
- "@
- ForEach($event in $el){
- $Content += "`n| " + $event.Index + " | " + $event.TimeGenerated + " | " + $event.EntryType + " | " + $event.Source + " | " + $event.InstanceId + " | " + $event.Message.replace("`n",", ").replace("`r",", ") + " |"
- }
- $Body = @{
- api_dev_key = 'devkey'
- api_paste_code = ($Content)
- api_paste_private = 2
- api_paste_name = $filename
- api_option = 'paste'
- api_user_key = $LoginKey
- api_paste_format = "markdown"
- }
- 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