Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Param(
- $selector = 'bars,notifications',
- $apikey = '{apikeyhere}'
- )
- $uri = "https://api.torn.com/user/?selections=$($selector)&key=$($apikey)"
- $username = 'email@domain.com'
- $password = Get-Content 'c:\fakepath\mysecurestring.txt' | ConvertTo-SecureString
- $cred = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $username,$password
- $to = 'you@you.com'
- $from = $username
- $smtpserver = 'smtp.example.com'
- $port = '465 OR 587'
- $subject = 'desired subject line of notification email'
- $request = Invoke-WebRequest -Uri $uri
- $content = $request.Content
- $contentObj = ConvertFrom-Json -InputObject $content
- $properties = Get-Member -InputObject $contentObj -MemberType NoteProperty
- $checkArray = New-Object -TypeName System.Collections.ArrayList
- ForEach ($property in $properties)
- {
- If ($property.MemberType -eq 'NoteProperty')
- {
- If ($Property.Name -ne 'chain' -AND $Property.Name -ne 'notifications' -AND $Property.Name -ne 'server_time')
- {
- $checkArray.Add($Property.Name)
- }
- }
- }
- ForEach ($item in $checkArray)
- {
- If ($contentObj.$item.fulltime -ne 0)
- {
- If ($contentObj.$item.fulltime -le 900)
- {
- $mins = $contentObj.$item.Fulltime/60
- $mins = [math]::Round($mins)
- $msg = "$item has $mins minutes remaining til full"
- Send-MailMessage -To $to -From $from -Body $msg -Subject $subject -smtpserver $smtpserver -UseSsl -Credential $cred -port $port
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement