Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.41 KB | None | 0 0
  1. $WsusServer = "servername"
  2. $UseSSL = $false
  3. $PortNumber = 80
  4. $TrialRun = $true
  5.  
  6. #E-mail Configuration
  7. $SMTPServer = "servername"
  8. $FromAddress = "email@domain.int"
  9. $Recipients = "email@domain.int"
  10. $MessageSubject = "WSUS :: Declining Itanium Updates"
  11.  
  12. Function SendEmailStatus($MessageSubject, $MessageBody)
  13. {
  14. $SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $Recipients, $MessageSubject, $MessageBody
  15. $SMTPMessage.IsBodyHTML = $true
  16. #Send the message via the local SMTP Server
  17. $SMTPClient = New-Object System.Net.Mail.SMTPClient $SMTPServer
  18. $SMTPClient.Send($SMTPMessage)
  19. $SMTPMessage.Dispose()
  20. rv SMTPClient
  21. rv SMTPMessage
  22. }
  23.  
  24. #Connect to the WSUS 3.0 interface.
  25. [reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | out-null
  26. $WsusServerAdminProxy = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer($WsusServer,$UseSSL,$PortNumber);
  27.  
  28. #$itanium = $WsusServerAdminProxy.SearchUpdates('Itanium') | ?{-not $_.IsDeclined}
  29. #$itanium += $WsusServerAdminProxy.SearchUpdates('ia64') | ?{-not $_.IsDeclined}
  30. #Although the above seems faster it also seaches in the description of the update so use the below just to search the title!
  31. $itanium = $WsusServerAdminProxy.GetUpdates() | ?{-not $_.IsDeclined -and $_.Title -match “ia64|itanium”}
  32. If ($TrialRun)
  33. {$MessageSubject += " Trial Run"}
  34. Else
  35. {$itanium | %{$_.Decline()}}
  36.  
  37. $Style = "<Style>BODY{font-size:11px;font-family:verdana,sans-serif;color:navy;font-weight:normal;}" + `
  38. "TABLE{border-width:1px;cellpadding=10;border-style:solid;border-color:navy;border-collapse:collapse;}" + `
  39. "TH{font-size:12px;border-width:1px;padding:10px;border-style:solid;border-color:navy;}" + `
  40. "TD{font-size:10px;border-width:1px;padding:10px;border-style:solid;border-color:navy;}</Style>"
  41.  
  42. If ($itanium.Count -gt 0)
  43. {
  44. $MessageBody = $itanium | Select `
  45. @{Name="Title";Expression={[string]$_.Title}},`
  46. @{Name="KB Article";Expression={[string]::join(' | ',$_.KnowledgebaseArticles)}},`
  47. @{Name="Classification";Expression={[string]$_.UpdateClassificationTitle}},`
  48. @{Name="Product Title";Expression={[string]::join(' | ',$_.ProductTitles)}},`
  49. @{Name="Product Family";Expression={[string]::join(' | ',$_.ProductFamilyTitles)}},`
  50. @{Name="Uninstallation Supported";Expression={[string]$_.UninstallationBehavior.IsSupported}} | ConvertTo-HTML -head $Style
  51. SendEmailStatus $MessageSubject $MessageBody
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement