pf100

v2.7.1-awmsdc.ps1

May 23rd, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. # sledgehammer\bin\awmsdc.ps1
  2. $get_ms_defcon={ # start of script block
  3. Param ($divider, $errmsg)
  4. $msg=$errmsg
  5. $progressPreference="silentlyContinue"
  6. If (test-netconnection www.askwoody.com http -InformationLevel Quiet){# not supported by windows 7
  7. Try{$WebResponse=Invoke-WebRequest "https://www.askwoody.com"}Catch{$WebResponse=""}
  8. If ($WebResponse.Statuscode -eq 200)
  9. {ForEach ($Image in $WebResponse.Images){$x=$Image.OuterHTML.ToString()
  10. If($x -like '*MS-DEFCON-*'){
  11. $msg="`r`n MS-DEFCON = "+$x.split('/')[8].split('.')[0].SubString(10,1) + "`r`n`r`n" + `
  12. "$divider`r`n`r`n" + `
  13. "MS-DEFCON 1: Current Microsoft patches are causing havoc. Don't patch.`r`n`r`n" + `
  14. "MS-DEFCON 2: Patch reliability is unclear. Unless you have an immediate, pressing need`r`n" + `
  15. " to install a specific patch, don't do it.`r`n`r`n" + `
  16. "MS-DEFCON 3: Patch reliability is unclear, but widespread attacks make patching prudent.`r`n" + `
  17. " Go ahead and patch, but watch out for potential problems.`r`n`r`n" + `
  18. "MS-DEFCON 4: There are isolated problems with current patches, but they are well-known`r`n" + `
  19. " and documented here. Check this site to see if you're affected and if`r`n" + `
  20. " things look OK, go ahead and patch.`r`n`r`n" + `
  21. "MS-DEFCON 5: All's clear. Patch while it's safe.`r`n`r`n" + `
  22. "$divider`r`n`r`n" + `
  23. "More info at https://www.askwoody.com`r`n`r`n" + `
  24. "$divider`r`n"
  25. Break
  26. }}}}
  27. $msg
  28. } # end of script block
  29. #
  30. $divider=":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
  31. $errmsg="`r`nUnable to retrieve MS-DEFCON rating from askwoody.com"
  32. $timeout=10 # timeout value in seconds
  33. $retry=3 # max number of retry count if request timed out
  34. <#
  35. :::::::::::::::::::::::::
  36. Internet connection check
  37. #>
  38. Clear-Host
  39. If(![Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){
  40. "`r`n`r`n`r`n`r`n"
  41. " Internet connection test failed.`r`n`r`n"
  42. " Microsoft Store or Windows Updates won't work without Internet.`r`n`r`n`r`n"
  43. "$divider`r`n`r`n`r`n"
  44. " --->>> Press ""Enter"" to continue if you're sure Internet is working.`r`n`r`n`r`n"
  45. "$divider`r`n`r`n`r`n"
  46. " It's safe to cancel now if needed. Your system will not be left in an unstable state.`r`n`r`n"
  47. " (Ctrl-C, Alt-F4, or click ""X"" to cancel and exit)`r`n"
  48. $return=Read-Host
  49. Clear-Host
  50. Exit # exit if no Internet connection ===> don't get MS-Defcon from askwoody.com
  51. }
  52. <#
  53. :::::::::::::::::::::::::::::::
  54. Get MS-Defcon from askwoody.com
  55. #>
  56. "Sledgehammer is attempting to retrieve MS-DEFCON rating from askwoody.com..."
  57. For($r=1; $r -le $retry; $r++){
  58. $job=start-job -ScriptBlock $get_ms_defcon -ArgumentList $divider, $errmsg
  59. $t=0;While($job.state -ne "Completed" -and $t -ne $timeout){start-sleep 1;$t++}
  60. Clear-Host
  61. If($t -ne $timeout){
  62. #"Answer returned after $t s - timeout value : $timeout s - retry count : $r"
  63. Receive-Job $job
  64. Exit
  65. }
  66. }
  67. #"No answer returned after waiting $timeout seconds $retry times"
  68. $errmsg
Advertisement
Add Comment
Please, Sign In to add comment