Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # get last powershell questions
- # http://meta.stackexchange.com/questions/43160/how-to-get-an-rss-feed-of-latest-questions
- $file = 'C:\redditposh.csv'
- $errorlog = 'C:\redditposherrors.txt'
- if (!(Test-Path $file)) {
- 'title,link,time' | Out-File $file
- }
- $last = ipcsv $file
- $smtpserver = 'smtp.domain.com'
- $reddit = ([xml](iwr reddit.com/r/powershell/new/.rss).content).feed.entry[0] | % {
- [pscustomobject]@{
- Title = $_.title
- Link = $_.link.href
- Time = Get-Date -f s
- }
- }
- if ($reddit.link -and @($last | ? link -eq $reddit.Link).Count -eq 0) {
- $reddit | epcsv $file -NoTypeInformation -Append
- $body = $reddit.title, $reddit.link -join "`n"
- Send-MailMessage -To $to -From $from -Subject 'reddit' -Body $body -SmtpServer $smtpserver
- if ($error[0].exception -notmatch 'module') {
- Get-Date >> $errorlog
- $error[0] >> $errorlog
- }
- }
- $poshorg = (iwr 'http://powershell.org/wp/forums/forum/windows-powershell-qa/').ParsedHtml.getElementById('bbp-forum-0').InnerHtml -split "`n" | select -Skip 9 -f 1 | % {
- [pscustomobject]@{
- Title = (Get-Culture).TextInfo.ToTitleCase(($_ -replace '.*title=(.*) ?href=.*', '$1').trim('" '))
- Link = $_ -replace '.*href="(.*)".*', '$1'
- Time = Get-Date -f s
- }
- }
- if ($poshorg.link -and @($last | ? link -eq $poshorg.Link).Count -eq 0) {
- $poshorg | epcsv $file -NoTypeInformation -Append
- $body = $poshorg.title, $poshorg.link -join "`n"
- Send-MailMessage -To $to -From $from -Subject 'poshorg' -Body $body -SmtpServer $smtpserver
- if ($error[0].exception -notmatch 'module') {
- Get-Date >> $errorlog
- $error[0] >> $errorlog
- }
- }
- $spiceworks = (iwr 'https://community.spiceworks.com/programming/topics?sort=recent').Links.href | ? {$_ -match 'community\.spiceworks\.com\/topic\/'} | select -f 1 | % {
- [pscustomobject]@{
- Title = (Get-Culture).TextInfo.ToTitleCase((Split-Path $_ -Leaf).Replace('-', ' ') -replace '^\d+ ')
- Link = $_
- Time = Get-Date -f s
- }
- }
- if ($spiceworks.link -and @($last | ? link -eq $spiceworks.Link).Count -eq 0) {
- $spiceworks | epcsv $file -NoTypeInformation -Append
- $body = $spiceworks.title, $spiceworks.link -join "`n"
- Send-MailMessage -To $To -From $from -Subject 'spiceworks' -Body $body -SmtpServer $smtpserver
- if ($error[0].exception -notmatch 'module') {
- Get-Date >> $errorlog
- $error[0] >> $errorlog
- }
- }
- $poshcom = (iwr http://powershell.com/cs/forums/230.aspx).links | ? {$_.href -match '^\/cs\/forums\/t\/'} | select href, outertext -f 1 | % {
- [pscustomobject]@{
- Title = (Get-Culture).TextInfo.ToTitleCase($_.outertext)
- Link = -join ('http://powershell.com', $_.href)
- Time = Get-Date -f s
- }
- }
- if ($poshcom -and @($last | ? link -eq $poshcom.Link).Count -eq 0) {
- $poshcom | epcsv $file -NoTypeInformation -Append
- $body = $poshcom.title, $poshcom.link -join ' '
- Send-MailMessage -To $To -From $from -Subject 'poshcom' -Body $body -SmtpServer $smtpserver
- if ($error[0].exception -notmatch 'module') {
- Get-Date >> $errorlog
- $error[0] >> $errorlog
- }
- }
- <# updates too often
- $so = ([xml](iwr http://stackoverflow.com/feeds/tag/powershell)).feed.entry[0] | % {
- [pscustomobject]@{
- Title = $_.title.'#text'
- Link = $_.link.href
- Time = Get-Date -f s
- }
- }
- if ($so.link -and @($last | ? link -eq $so.Link).Count -eq 0) {
- $so | epcsv $file -NoTypeInformation -Append
- $body = $so.title, $so.link -join "`n"
- Send-MailMessage -To $To -From $from -Subject 'so' -Body $body -SmtpServer $smtpserver
- if ($error[0].exception -notmatch 'module') {
- Get-Date >> $errorlog
- $error[0] >> $errorlog
- }
- }#>
Add Comment
Please, Sign In to add comment